Setting up a J2EE JDBC connection

If you are connecting to a relational database at run time, you need to define a data source for use with your program. The directions are in the help system of the WebSphere Sever administrative console.

When you define a data source, assign values to the following properties:

JNDI name

Specify a value that matches the name to which the database is bound in the JNDI registry:

  • If you are defining a data source which connects to a database that your J2EE module uses by default, make sure that the JNDI name specified in the data source definition matches the value of the vgj.jdbc.default.database property in the J2EE deployment descriptor used at run time

  • If you are defining a data source that will be accessed when the system function sysLib.connectionService runs, make sure that the JNDI name specified in the data source definition matches the value of the appropriate vgj.jdbc.database.SN property in the J2EE deployment descriptor used at run time

Database name

Specify the name of your database, as known to the database management system

User ID

Specify the user name for connecting to the database.

If the data source definition refers to the default database, the value you specify in the User ID field is overridden by any value set in the vgj.jdbc.default.userid property of the J2EE deployment descriptor used at run time, but only if you have specified values for both vgj.jdbc.default.userid and vgj.jdbc.default.password. Similarly, if the data source definition refers to a database that is accessed by way of the system function sysLib.connect or sysLib.connectionService, the value you specify in the User ID field is overridden by any user ID that you specify in the call to that system function, but only if the call passes both a user ID and password.

You specify the name when setting up the authentication alias. To reach the display where you can define that alias, follow this sequence in the Administrative Console: Security > GlobalSecurity > Authentication > JAAS Configuration > J2C Authentication Data.

Password

Specify the password for connecting to the database. If the data source definition refers to the default database, the value you specify in the Password field is overridden by any value set in the vgj.jdbc.default.password property of the J2EE deployment descriptor used at run time, but only you have specified values for both vgj.jdbc.default.userid and vgj.jdbc.default.password. Similarly, if the data source definition refers to a database that is accessed by way of the system function sysLib.connectionService, the value you specify in the Password field is overridden by any password that you specify in the call to that system function, but only if the call passes both a user ID and password.

You specify the password when setting up the authentication alias. To reach the display where you can define that alias, follow this sequence in the Administrative Console: Security > GlobalSecurity > Authentication > JAAS Configuration > J2C Authentication Data.

You may define multiple data sources, in which case you use the system function sysLib.connectionService to switch between them.

For details on the meaning of the deployment descriptor properties, including details on how the generated values are derived, see Java run-time properties (reference).

Related tasks
Setting up the J2EE run-time environment for EGL-generated code
Understanding how a standard JDBC connection is made

Related reference
Java run-time properties (details)
JDBC driver requirements in EGL
sysLib.connectionService