COBOL and JDBC can use a common database connection. To achieve this, use a combination of EXEC SQL statements, depending on how the connection is opened.
- When Java opens the connection
-
- Pass the connection object to COBOL.
- Use EXEC SQL BIND CONNECTION to establish the connection.
- When done using the connection, use EXEC SQL UNBIND CONNECTION if Java still requires access to it, or use EXEC SQL DISCONNECT if Java no longer requires access.
- When COBOL opens the connection
-
- Use EXEC SQL GET CONNECTION to get a connection object to pass to Java.
- When done using the connection, use EXEC SQL UNBIND CONNECTION if Java still requires access to it, or use EXEC SQL DISCONNECT if Java no longer requires access.
Note: EXEC SQL UNBIND CONNECTION closes cursors but does not close the connection.