Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML
 
 
Search All Tutorials
  

 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 
JDBC
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

New Features in JDBC 4.0

                         

Introduction

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: 

Class.forName("FullyQualifiedNameOfTheDriverClass");

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:

\\META-INF\\services\\FullNameOfTheService
 
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,

\\META-INF\\services\\java.sql.Driver

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.

                         

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (post your own) View All Comments Latest 10 Comments:

ihave doubt about jdbc can i give customer id no during runtime environment can u explain how can give to cusotomer id to employee table automatically

Posted by subramanyam on Tuesday, 02.19.08 @ 09:30am | #48961

that's what i'm searching

Posted by anish chapagain on Thursday, 11.8.07 @ 02:53am | #36465

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.