Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training

New Features in JDBC 4.0

In this section, you will learn about the new features in JDBC 4.0.


JDBC Video Tutorial: Create, Read, Update and Delete (CRUD) Operation examples JDBC Video tutorial - How to read Data from MySQL Database? JDBC Video tutorial - How to delete Data in a MySQL Database? Solving java.lang.ClassNotFoundException: com.mysql.jdbc.Driver exception JDBC Video tutorial - How to update Data in a MySQL Database? JDBC Video Tutorial- How to insert data into MySQL database table? JDBC Video Tutorial: How to download JDBC Driver for MySQL? JDBC Tutorial - Writing first JDBC example and running in Eclipse Java Cross Join MySQL Database Connectivity Example In Java Change Column Name in MySQL Java Mysql Connection Example JDBC ODBC Connection In Java ResultSet In Java Prepared Statement Example JdbcRowSet interface Java JdbcRowSet Example First Step towards JDBC! JDBC Training, Learn JDBC yourself Jdbc Get Column Names JDBC Example with MySQL JDBC Prepared Statement Update JDBC Prepared Statement Insert JDBC Prepared Statement Example JDBC Prepared statement Close JDBC Prepared Statement Addbatch JDBC Nested Resultset JDBC-Odbc Connection JDBC-Odbc Connectivity JDBC Insert Preparedstatement JDBC Insert Null JDBC Get Metadata JDBC Insert Record Jdbc Insert Statement JDBC Meta Data Get tables Jdbc Mysql Connection String Jdbc Mysql Connection Url JDBC Next Jdbc Get Connection JDBC Get Int JDBC Exception JDBC Get Row Count JDBC Functions JDBC Fetch JDBC Execute Update Example JDBC Execute Statement JDBC Execute Query JDBC Drive For Mysql JDBC Connectivity Code In Java JDBC connection timeout

New Features in JDBC 4.0



Java database connectivity (JDBC) is the Java Soft specification of the API. It allows Application Programs to interact with the Database to access the Relational Data. Typically the JDBC API consists of a set of interfaces and classes written in the Java programming language. The applications can be written to connect to databases using these standard interfaces and classes and also to process the results by sending queries written in SQL. Furthermore the back-end Database session can be connected by JDBC API which can execute the Queries to get the Results.
Some of the new set of features which come along with Mustang is JDBC 4.0 are:

  1. No need for Class.forName("DriverName")

  2. Changes in Connection and Statement Interface

  3. Better Pools

  4. Using ResultSet Becomes More Flexible

  5. More APIs Become Available

The three most important features of Driver and Connection Management in JDBC are described below with some new features and enhancements.

1. Getting Connected Becomes Easier

This is one of the most important feature in JDBC that has relieved the developers from loading the driver explicitly. Exactly, you got it right, no need to explicitly load the driver by calling Class.forName anymore. So from now on don't bother to load the driver because the DriverManager will automatically load the driver found in the application CLASSPATH while your application tries to connect the database for the first time. However it is still preferred to create an appropriate DataSource object to retrieve a connection. Since the properties of data source instance can be modified which allows portability and transparency, there is no need to modify any application code to connect to a different  database instance. Hence to retrieve a connection there is no need to change any application code to connect to a different database instance that requires loading a different driver.

For example: Earlier the programmers used to manually load the drivers before making any Database Calls. The code which was used by the programmers is: 


The disadvantage is that the code will be changed if the Database Driver vendor wants to change the class name. Now this problem doesn't persist anymore. With the help of Service Provider Mechanism available from Java 5, the Driver will be Loaded Automatically by the JVM provided that the Jar files corresponding to the Driver Class are in the appropriate class path.  

To understand this mechanism consider two entities, one is the service which contains a set of interfaces and the other entity is the provider who gives a well-defined Implementation for the Service. Now to maintain a directory structure, this service is packaged as a Jar by the provider. The structure of a directory is:

After maintaining the directory structure, if the JDBC Driver Provider wants to make his implementation as a Service then he has to maintain the file name along with the directory structure as,


Rememeber the file should only contain one entry that is the Name of the Provider Class. The function of this entry is to implement the Driver. Also the name of the file is java.sql.Driver in the above code. For instance the content of the file in My SQL would be,

File - Java.sql.Driver
com.mysql.jdbc.Driver # Class name of the Driver

Hence any Java program will automatically load the JDBC driver by the procedure. Moreover if the application class-path contains multiple drivers then the preference will be given to the first matching driver only ignoring the rest of the drivers.  

2. Using ResultSet Becomes More Flexible

Several important features of ResultSet interfaces hierarchy are described below:

  1. The ResultSet provided by the RowSet sub-interface is scrollable, updateable, and offline-editable . The JDBC programming has become much more easier and flexible due to the current version's support for the SQLXML data type along with these features.

  2. Another feature of the ResultSet is the WebRowSet sub-interface. This interface provides the ability to read data from database tables. Moreover it is used to serialize the data to an XML document, and deserialize from XML back to result set.


Share on Google+Share on Google+

New Features in JDBC 4.0

Posted on: June 30, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: New Features in JDBC 4.0   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image