A Developer's Diary

Showing posts with label JDBC. Show all posts
Showing posts with label JDBC. Show all posts

Oct 2, 2013

Automatically registering the jdbc driver

A jdbc driver can be registered with the Driver Manager in four ways.
1. Automatic Registration
2. Using Class.forName("DRIVER_NAME")
3. Using property -Djdbc.drivers=DRIVER_NAME
4. Explicit registration using the new operator

Automatic Registration
Starting JDBC 4.0, the DriverManager methods getConnection() and getDrivers() have been enhanced to support automatic registration of the driver using the Service Provider mechanism.

Read more ...

Oct 22, 2012

Configuring and retrieving a DataSource object

In the JDBC API, a DataSource object is a means to access a database. A DataSource object is identified by set of properties which is used to communicate with the server. These properties include information such as the location of the database server, the name of the database, the protocol used to communicate with the server, the username and password of the privileged database user.
In the application server, a data source is known as JDBC Resource

The rest of the post demonstrates how to configure a JDBC Resource in GlassFish application server and retrieve the same data source using JNDI through a simple web servlet

Read more ...