Wednesday, December 15, 2010

How to check JDBC driver version

Oracle Support Note: 396187.1 provides instructions on how to install a sample web application to test the database driver. It works great, and it is pretty simple process as shown below:

1) download drvtest.ear from the Oracle support
2) Deploy it desired container
3) Goto http://:/drvtest/dbdetails.jsp
enter username/password/url
it provide information like below:

JDBC Driver details
=============
JDBC Driver Name is ........ Oracle JDBC driver
JDBC Driver Version is ..... 10.1.0.5.0
JDBC Driver Major Version is 10
JDBC Driver Minor Version is 1
=============
Database Details
=============
Database Product Name is ... Oracle
Database Product Version is Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options



I found couple of issues with drvtest.ear file which forced me to write another sample app:
1. This application opens connection and doesn't close
2. This application is struts based and causes problem when you deploy oc4j_soa container (at least in 10.1.3.3.x). It works fine on other container
3. Some time you want to use data source instead of direct connection

I decompiled the code and modified for my need, and it was very easy to expose that piece of java code as web service and provide two separate operations:

InitialContext initialContext = new InitialContext();
DataSource dataSource = (DataSource) initialContext.lookup(dataSourceName);
connection = dataSource.getConnection();
DatabaseMetaData meta = connection.getMetaData();



1. You can deploy the CustomDriverTest.ear to any oc4j container
2. Goto http://host:port/CustomDriverTest/DriverCheckService?WSDL or http://host:port/CustomDriverTest/DriverCheckService
it provides both operation - test by direct database connection or test by data source.
3. It certainly closes connection after providing db information

No comments: