Database-side JDBC routines and nested connections

Most database-side JDBC routines need to share the same transaction space as the statements that called them.

The reasons for this are:

In order to use the same transaction, the routine must use the same connection as the parent SQL statement in which the routine was executed. Connections re-used in this way are called nested connections.

Use the connection URL jdbc:default:connection to re-use the current Connection.

The database donnection URL jdbc:default:connection allows a Java method to get the Connection of the SQL statement that called it. This is the standard (SQL standard, Part 13, SQL Routines and Java) mechanism to obtain the nested connection object. The method would get a Connection as follows:

Connection conn = DriverManager.getConnection(

URL attributes are not supported as part of this connection URL. Any URL attributes specified in a Properties object, user name, or password that are passed to a java.sql.DriverManager.getConnection() call will be ignored.

Loading a JDBC driver in a database-side routine is not required.

Related concepts
Database-side JDBC routines using non-nested connections
Database-side JDBC routines and SQLExceptions
User-defined SQLExceptions