Documentation

(jvx:server:storage)

DataSourceHandler and DBCredentials

Translations of this page:

This is an old revision of the document!


Simple integration of multiple databases is an easy task with JVx. Configuration is usually completed via the application's, config.xml file. This allows for easy access in the LifeCycle objects:

config.xml
<?xml version="1.0" encoding="UTF-8"?>
 
<application>
  <securitymanager>
    <class>com.sibvisions.rad.server.security.DBSecurityManager</class>
    <database datasource="mydb" />
  </securitymanager>
 
  <datasource>
    <db name="mydb">
      <url>jdbc:oracle:thin:@localhost:1521:mydb</url>
      <username>user</username>
      <password>password</password>
    </db>
    <db name="masterdb">
      <url>jdbc:derby://localhost:1527/masterdb</url>
      <username>master</username>
      <password>master</password>
    </db>
  </datasource>
</application>

To access:

IConfiguration config = SessionContext.getCurrentSessionConfig();
 
dba = DBAccess.getDBAccess(DBSecurityManager.getCredentials(config));
dba.open();

using the DataSource of the SecurityManager. To access DataSources independently from the Security Manager we use DataSourceHandler:

IConfiguration config = SessionContext.getCurrentSessionConfig();
 
DBCredentials cred = DataSourceHandler.createDBCredentials(config, "masterdb");
 
dba = DBAccess.getDBAccess(cred);
dba.open();


Hint

The DB Security Manager allows the use of a standard DataSource without any additional configuration effort:

config.xml
<?xml version="1.0" encoding="UTF-8"?>
 
<application>
  <securitymanager>
    <class>com.sibvisions.rad.server.security.DBSecurityManager</class>
  </securitymanager>
 
  <datasource>
    <db name="default">
      <url>jdbc:oracle:thin:@localhost:1521:mydb</url>
      <username>user</username>
      <password>password</password>
    </db>
  </datasource>
</application>

The Security Manager uses the DataSource named “default” as the standard connection.

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