No need to explicitly load the driver by calling Class.forName anymore.
In JDBC 4, invoking the getConnection() on DriverManager will automatically load a driver.
Connection management enhancements
1. Method to check whether a Connection object is still valid / active or not
int tenSeconds = 10;
The argument is the Timeout value.
The value false will be returned if the timeout interval exceeds and if the value returned is 0 for the time-out interval that indicates an Infinite Time-out Duration.
2. Methods to set or get metadata for a database connection
Connection.getClientInfo()
Connection.setClientInfo(Properties)
Connection.setClientInfo(String,String)
Connection.getClientInfo(String)
3. Methods added to Statement interface
Statement.isClosed()
Returns true, if the Statement Object is closed.
Statement.setPoolable(boolean)
Statement.setPoolable(true) will use implementation to pool this Statement Object for better performance.
By default, only PreparedStatement and CallableStatementare pooled by the Implementation.
Statement.isPoolable()
Checks if statement object will use pooling.
Using ResultSet Becomes More Flexible
1. RowSet (child interface of ResultSet) is scrollable, updateable, and offline-editable.
2. WebRowSet (child interface of ResultSet) provides the ability to read data from database tables.
It is used to serialize the data to an XML document, and deserialize from XML back to result set.
Support for RowId data type
JDBC introduces support for ROWID, a data type that had been in use in database products even before it became part of the SQL.
SQL exception handling enhancements
JDBC 4 addresses the error handling beautifully.
As databases are often remotely accessible resources, problems such as network failures is common and it can cause exceptions when executing a database operation. SQL statements can also cause exceptions.
Prior to JDBC 4, most JDBC operations generated a simple SQLException.
SQL XML support
DataSet implementation of SQL using Annotations
The JDBC 4.0 specification leverages annotations to allow developers to associate a SQL query with a Java class without a need to write a lot of code to achieve this association.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.