More APIs Become Available

In this section, you will learn some APIs and new methods have been added in JDBC 6.0.

More APIs Become Available


3. More APIs Become Available:

Some APIs and new methods have been added in JDBC 6.0.

More APIs have been added to this version of JDBC to provide access to commonly implemented features of SQL:2003. In addition, several new methods have been added to commonly used interfaces to support easier and better data manipulation.

Now, let's review some working code and discuss the result of the Example1 class below. It will connect to an embedded Apache Derby database and display the query results in the console. Although JDBC 4.0 has been out for several months now, I found Apache Derby is the only database to provide a driver that even partially supports the JDBC 4.0 specification at the time of this writing (March 2007). All examples in this article are developed using JDK 1.6 and Apache Derby database version For all code examples, I will show only snippets of the actual Java source file that are relevant to the discussion. See the Resources section for complete sample code discussed in this article.


4. Changes in Connection and Statement Interface:

Some new features have been added to the Connection interface. However, first of all lets see the methods which are already in use to check whether a Connection object is still valid/active or not. 

int tenSeconds = 10;

In the above code the argument that specifies the time duration taken by the API to check whether the Connection is valid or not is Connection.isValid(int) that is Connection.isValid(tenSeconds);. This 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. Moreover the methods which are used for populating and retrieving the Client Information about a particular driver are:

Connection.setClientInfo(Properties) methods

also the methods which are used to retrieve the Client information individually are:


 Now lets see the methods which have been added to the Statement interface.

  1. Statement.isClosed() - If the Statement Object is closed it will return true by calling the Statement.close() method.
  2. Statement.setPoolable(boolean) - The call to Statement.setPoolable(true) will only act as a request to the Implementation to pool this Statement Object for better performance.
  3. Statement.isPoolable() - By default, only PreparedStatement and CallableStatement are pooled by the Implementation. Not all the implementations may support this feature and hence Applications should not depend on this feature always.