Keywords: javax.sql package, JDBC 2.0, standard interfaces, javax.sql.PooledConnection, Connection pooling, javax.sql.DataSource, Data sources, javax.sql.XAConnection, javax.sql.XADataSource, creating a database for, shutting down a database for

# javax.sql: JDBC Interfaces

This section documents the JDBC interfaces that Derby implements for J2EE compliance.

For more details about these interfaces, see the API documentation for your version of the Java Development Kit, which you can find at http://java.sun.com/javase/reference/api.jsp.

- javax.sql.DataSource

  An interface that is a factory for connections to the physical data source that the object represents. An object that implements the DataSource interface will typically be registered with a naming service based on the Java Naming and Directory (JNDI) API.

- javax.sql.ConnectionPoolDataSource and javax.sql.PooledConnection

  Establishing a connection to the database can be a relatively expensive operation in client/server environments. Establishing the connection once and then using the same connection for multiple requests can dramatically improve the performance of a database.

  The Derby implementation of `ConnectionPoolDataSource` and `PooledConnection` interfaces allows a connection pool server to maintain a set of such connections to the resource manager (Derby). In an embedded environment, connections are much cheaper and connection pooling is not necessary.

- javax.sql.XAConnection

  An XAConnection produces an XAResource, and, over its lifetime, many Connections. This type of connection allows for distributed transactions.

- javax.sql.XADataSource

  An XADataSource is simply a ConnectionPoolDataSource that produces XAConnections.

In addition, Derby provides three methods for XADataSource, DataSource, and ConnectionPoolDataSource. Derby supports a number of additional data source properties:

- setCreateDatabase(String create)

  Sets a property to create a database at the next connection. The string argument must be "create".

- setShutdownDatabase(String shutdown)

  Sets a property to shut down a database. Shuts down the database at the next connection. The string argument must be "shutdown".

Note: Set these properties before getting the connection.
Parent topic: J2EE Compliance: Java Transaction API and javax.sql Interfaces
Related reference
The JTA API