# Programming database-side JDBC routines

Methods invoked within an application are called application-side methods. Methods invoked within Derby are called database-side routines.

An application-side method can be exactly the same as a database-side routine. The only difference is where you invoke them. You write the method only once. Where you invoke the method--within the application or within an SQL statement--determines whether it is an "application-side" or a "database-side" method.

- 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.
- Database-side JDBC routines using non-nested connections
  A database-side JDBC routine can create a new connection instead of using a nested connection. Statements executed in the routine will be part of a different transaction, and so can issue commits and rollbacks.
- Database-side JDBC routines and SQLExceptions
  It is possible to code database-side routines, like application-side methods, to catch SQLExceptions. SQLExceptions that are caught within a routine are hidden from the calling application code.
- User-defined SQLExceptions
  When the execution of a database-side method raises an error, Derby wraps that exception in an SQLException with an SQLState of 38000.

Parent topic: Derby server-side programming
Related concepts
Programming trigger actions
Nested connections