# Database-side JDBC procedures and nested connections

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

The reasons for this are:

- to avoid blocking and deadlocks
- to ensure that any updates done from within the method are atomic with the outer transaction

In order to use the same transaction, the procedure must use the same connection as the parent SQL statement in which the method 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 Connection 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`:

    Connection conn = DriverManager.getConnection(
        "jdbc:default:connection");

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

- Requirements for database-side JDBC procedures using nested connections
  In order to preserve transactional atomicity, database-side JDBC procedures that use nested connections have the following limitations.

Parent topic: Programming database-side JDBC procedures
Related concepts
Database-side JDBC procedures using non-nested connections
Database-side JDBC procedures and SQLExceptions
User-defined SQLExceptions