Using an SQL database connection at run time

To use an SQL connection at run time, you must point to the connection from your project's build descriptor and, for EGL Web projects, set options in the J2EE deployment descriptors based on information in the connection.

Prerequisites

You will need a working connection to an SQL database, or you can create one in the process. For instructions on setting up this connection, see Creating an SQL database connection.

Creating the runtime connection for EGL projects

  1. Double-click the build descriptor for your project. Typically, the build descriptor file is located in the top level of the EGLSource directory of your project and is named project.eglbld. The build descriptor opens in the build parts editor.
  2. Select the database connection to use from the Load DB options using Connection list. If you have not already created this connection, see Creating an SQL database connection.
    When you select a connection, the build parts editor updates the following build descriptor options to match the connection:
    • dbms
    • sqlDB
    • sqlID
    • sqlJDBCDriverClass
    • sqlPassword
    • sqlValidationConnectionURL

    In addition, you must provide a value for the sqlJNDIName build descriptor option. This is the JNDI name for the database, which you provide in the default Java build descriptor.

  3. Save the build descriptor and close the window.
  4. Generate any parts that use the database connection.

Error conditions

EGL uses a different process to connect with the database at run time than it does at design time. These differences might result in errors when you try to run your code. These errors are not likely to occur anywhere except in the debugger:
  • EGL might not be able to find the Java™ class containing the driver for your database manager, even though you specified a Class location in the New Connection wizard. To correct this error, make sure the driver is on the classpath for your project:
    1. Right-click on your project name in the Project Explorer view and click Properties from the pop-up menu.
    2. Select Java Build Path from the left pane of the Properties window.
    3. Click the Libraries tab on the Java Build Path page.
    4. If the correct class location is not displayed, click Add External JARs and add the class and location. You can copy this information from your Connection; see Editing or deleting an SQL database connection
    .

Feedback