Each run unit has a single current connection. By default, the connection has the name you specify for the database; you can change the name by using the sqlLib.defineDatabaseAlias() function.
The sqlLib.connect() function overrides the default SQL connection that you create through the New Connection wizard in the workbench. For more information on this wizard, see Creating an SQL database connection in the EGL Programmer's Guide. If you are migrating code from VisualAge® Generator or EGL version 5, see connectionService().
The sqlLib.connect() function does not return a value, but it does set the system variables in sqlLib.sqlData. See sqlLib.sqlData (EGL system variable).
sqlLib.connect( database STRING in, userID STRING in, password STRING in [, disconnectOption DisconnectKind in [, isolationLevel IsolationLevelKind in [, commitControl CommitControlKind in]]]] )
This password is automatically encrypted if you pass a string literal to the function. For more information, see Encrypting passwords in the EGL Programmer's Guide. Also see the "Compatibility" section of this topic.
If you use type1 as the value of commitScope, the value of the disconnectOption parameter must be set (or allowed to default) to explicit.
For more information, refer to the JDBC documentation from Sun Microsystems, Inc.
You can switch from autoCommit to noAutoCommit temporarily. For information, see beginDatabaseTransaction().
The following is an example of the sqlLib.connect() function:
sqlLib.connect(myDatabase, myUserid, myPassword);
Platform | Issue |
---|---|
COBOL generation | All sqlLib.connect() parameters, with the exception of database, are ignored. |
Java generation | The Tomcat J2EE server ignores the userID and password from the sqlLib.connect() function and uses the values from its server configuration. |
J2EE | To default to the user ID and password associated with the data source (defined for the JNDI name), use blanks or the empty string ("") for userID and password. |