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: 198
Joined: Mon Sep 28, 2009 1:56 pm

Return to Development