JDBC 4 Features, JDBC 4.0 Features


JDBC 4 Features, JDBC 4.0 Features

Learn the new features of JDBC 4.0. The JDBC 4.0 is release with many new features.

Learn the new features of JDBC 4.0. The JDBC 4.0 is release with many new features.

JDBC 4 Features

In this section we are discussing about the new features of JDBC 4.0.

Jdbc 4.0 ships with Java SE 6 with a lot of new and improved features such as improved BLOB and CLOB support, SQL XML data type etc.

Here are some features of jdbc 4.0

1. Auto loading of Driver by JVM

In previous versions, we used to load driver using Class.forName() method. It's no longer necessary to do like this and now getConnection() method of DriverManager class is able to load the appropriate driver.

2. Standard Connection Factory Management

Previously, we needed data source url to make the connection. But now provide datasource parameters and connection factory will create it for you.

3. Enhanced Connection and Statement Interface

Jdbc 4.0 added new methods to satisfy the new features. For example,Connection interface provides isValid method to check weather the status of Connection is valid, methods to get and set driver supported clients information. Statement interface provides isClosed method to check if the Connection is closed. There are lot more methods added in these interfaces.

4. New interface RowID to support the ROWID data type

For databases like Oracle which supports ROWID datatype, jdbc 4.0 added new interface RowId.

5. Use of Annotated SQL queries

Annotations added in jdbc 4.0 has made developers work easy. Developers can now write sql queries using annotations that greatly reduces the amount of code required.

6. New Exception classes

Jdbc 4.0 added new Exception Handling classes i.e. subclasses of SQLException which handles transient and non transient exceptions. SQLException also added new 'for each' loop feature to iterate through generated exceptions.

7. National Character Set Conversion Support

Jdbc 4.0 added new datatypes and methods to handle National Character Set. Data types NCHAR, NVARCHAR, LONGNVARCHAR, and NCLOB and Methods like setNString(), getNClob(), updateNClob() etc. are added.

8. Enhanced support for BLOBs and CLOBs

Jdbc 4.0 added new methods to handle large objects like BLOB and CLOB. For example, createBlob(), createClob() and createNClob() methods can be used to create BLOB, CLOB and NCLOB objects respectively.

9. XML support

JDBC provides java.sql.SQLXML interface to support the XML database data type. XML type is used to store XML value as a column value in a row. It provides several methods for getting XML value as a String, a Reader or Writer, or Stream. XML value can be parsed with DOM, SAX etc.