--DataSourceHandler and DBCredentials
1 post
• Page 1 of 1
--DataSourceHandler and DBCredentials
This article is outdated - please use our new system at
https://doc.sibvisions.com
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:
- Code: Select all
<?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:
- Code: Select all
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:
- Code: Select all
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:
- Code: Select all
<?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.
-
Development@SIB - Posts: 325
- Joined: Mon Sep 28, 2009 1:54 pm
1 post
• Page 1 of 1