SQLJ connection technique 6: Use the default connection
SQLJ connection technique 6 uses the default connection to connect to the data source. It should be used only in situations where the database thread is controlled by another resource manager, such as the Java stored procedure environment.
About this task
The default connection context can be:
- The connection context that is associated with the data source that is bound to the logical name jdbc/defaultDataSource
- An explicitly created connection context that has been set as the default connection context with the ConnectionContext.setDefaultContext method. This method of creating a default connection context is not recommended.
In a stored procedure that runs on Db2 for z/OS®, or for a CICS® or IMS application, when you use the default connection, Db2 for z/OS uses the implicit connection.
Example
#sql {SELECT LASTNAME INTO :empname FROM EMPLOYEE
WHERE EMPNO='000010'}; // Use default connection for
// executing an SQL statement