This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Get custom database settings from config.xml

General questions regarding the development with JVx.

Get custom database settings from config.xml

Postby jvxdev » Mon Mar 07, 2016 2:50 pm

My config.xml contains multiple datasources:

Code: Select all
    <db name="default">
    <db name="external">

I tried to call:

Code: Select all

but got an Exception:

Code: Select all
java.lang.IllegalArgumentException: Missing index

I need the "external" datasource. Do I need to parse the file with an XML parser?
Posts: 19
Joined: Fri Mar 04, 2016 12:40 pm

Re: Get custom database settings from config.xml

Postby Support@SIB » Mon Mar 07, 2016 3:16 pm

The solution is super simple:

Code: Select all
String url = SessionContext.getCurrentSessionConfig().getProperty(


Code: Select all
XmlNode node = SessionContext.getCurrentSessionConfig().getNode(

But it's better to use DBCredentials:

Code: Select all
DBCredentials cred = DataSourceHandler.createDBCredentials(
                           SessionContext.getCurrentSessionConfig(), "external");

JVx has a smart class for reading custom XML files, see XmlWorker and XmlNode
User avatar
Posts: 349
Joined: Mon Sep 28, 2009 1:56 pm

Re: Get custom database settings from config.xml

Postby Clopton » Wed Oct 11, 2017 7:31 pm

This worked like a charm. Can't believe I didn't think of that. Thanks a lot.
Posts: 1
Joined: Tue Oct 03, 2017 4:16 pm

Return to Development