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. If you are using WebSphere® Application Server, the directions are in the help system of the administrative console. If you are using another supported J2EE server, check the documentation for your server for instructions on defining the data source.

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 vgLib.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 sysLib.connect or vgLib.connectionService system functions, 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 vgLib.connectionService system function, 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 vgLib.connectionService to switch between them.