If the purpose of a resource binding is to specify the connection used for database access, the definition is called a database binding.
If you reference an Eclipse connection profile, any subsequent change to that profile is available to your code at development and deployment time. After the EGL deployer has packaged the application, though, the changes have no effect on the deployed code unless you redeploy the application.
For details on defining an SQL database binding in the EGL deployment descriptor, see Adding an SQL database binding to the EGL deployment descriptor.
You enable a future connection to a database by declaring a connection variable. The connection itself occurs when you first run a database-access statement that uses the variable.
myDataSource SQLDataSource? { @Resource {uri="binding:"MyDatabaseBinding"} };
myJNDIDataSource SQLJNDIDataSource? {
{ @Resource {uri="binding:MyDatabaseJNDIBinding"} };
Your code interacts with either variable in the same way, and the use of the SQLDataSource type is sufficient in many cases. Here is an exception: if your subsequent logic uses the EGL isa operator to test whether a variable is of type SQLDataSource or SQLJNDIDataSource, you must use the SQLJNDIDataSource type for JNDI data sources and must use the SQLDataSource type for others.
myDataSource SQLDataSource? =
SysLib.getResource("binding:MyBinding");
myJNDIDataSource SQLDataSource? =
SysLib.getResource("binding:MyJNDIBinding");
myOtherJNDIDataSource SQLJNDIDataSource? =
SysLib.getResource("binding:MyOtherJNDIBinding");
connectURL string = "jdbc:derby:SomeDB;create=true;";
properties Dictionary{user = "MyID", password = "MyPassword"};
myDataSource SQLDataSource? = new SQLDataSource(connectURL, properties);
connectURL string = "jdbc/myDataSource";
properties Dictionary{user = "MyID", password = "MyPassword"};
myJNDIDataSource SQLJNDIDataSource? = new SQLJNDIDataSource(connectURL, properties);
connectURL string = "jdbc/myDataSource"; myJNDIDataSource SQLJNDIDataSource? = new SQLJNDIDataSource(connectURL);
For a JNDI connection, if security detail is passed to a data source that operates under container-managed security, the result is not determined by the generated application or by the EGL runtime code. For details on what happens, see the documentation provided by the specific Java DataSource class in use.
For details on these capabilities, see the "SQLDataSource external type" help topic, which is subordinate to "eglx.persistence.sql.package." The details there apply to both SQLDataSource and SQLJNDIDataSource.
For further details, see EGL support for relational databases.