Previous Topic Next topic Print topic


Sharing Database Connections Between Java and COBOL

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
  1. Pass the connection object to COBOL.
  2. Use EXEC SQL BIND CONNECTION to establish the connection.
  3. 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
  1. Use EXEC SQL GET CONNECTION to get a connection object to pass to Java.
  2. 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.
Previous Topic Next topic Print topic