JDBC - Connection

Jdbc Class Architecture


Code Design - Connection Pool in Jdbc

Implementation: https://github.com/swaldman/c3p0

Data Source

The DataSource interface, introduced in JDBC 2.0 Optional Package, is connection factory.

Data source provides connection pooling of connection (ie DriverManager).

Connection conn = dataSource.getConnection(user, passwd);


The Java Naming and Directory Interface (JNDI) API provides a uniform way for applications to access remote services over the network

Using the JNDI API, applications can access a DataSource object by specifying its logical name. A naming service using the JNDI API maps this logical name to a corresponding data source. This scheme greatly enhances portability because any of the DataSource properties, such as portNumber or serverName, can be changed without impacting the JDBC client code. This is particularly useful in the three-tier environment (J2ee)

Use of a JNDI-based naming service to deploy a new VendorDataSource object.

Registering a DataSource object with a JNDI-based naming service

// Create a VendorDataSource object and set some properties
VendorDataSource vds = new VendorDataSource();
vds.setDescription("data source for inventory and personnel");
// Use the JNDI API to register the new VendorDataSource object.
// Reference the root JNDI naming context and then bind the
// logical name "jdbc/AcmeDB" to the new VendorDataSource object.
Context ctx = new InitialContext();
ctx.bind("jdbc/AcmeDB", vds);

Discover More
Jdbc Class Architecture
JDBC (Java Database Connectivity)

JDBC – Java Database Connectivity is a Java API that provides access to most popular databases or to other tabular data sources. It provides methods for querying and updating data in a database. JDBC...
Jdbc Class Architecture
JDBC - Data Dictionary

A Connection's database is able to provide information describing: its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on. This information...
Jdbc Class Architecture
Jdbc - Driver Manager

java/sql/DriverManagerDriverManager JDBC 4.1 specification, when the DriverManager is trying to establish a connection: it calls the driver’s connect method and passes the URL. If the Driver...
Jdbc Class Architecture
Jdbc - Statement

Statement objects are created by Connection objects The java/sql/StatementStatement interface defines methods for executing SQL statements. There is also two subclasses: The PreparedStatement interface...

Share this page:
Follow us:
Task Runner