2
votes

I have inherited a VM (linux OS) from someone. It has a java app "bob" deployed/running inside of tomcat and oracle 11.2.0 database. I wrote a simple db connection in beanshell (lightweight of java) as following example and it executed fine however a question came to my mind.

Connection con = DriverManager.getConnection("jdbc:oracle:thin:hostname:1521:sidname","username","password");

I noticed that ojdbc14.jar found /somepath/tomcat/webapps/bob/WEB-INF/lib/ojdbc14.jar AND from oracle installation /somepath/oracle/product/11.2.0/xe/jdbc/lib/{ojdbc5.jar,ojdbc6_g.jar,ojdbc6.jar} three ojdbc jar files found.

Which jar file in this case thin driver used in order to make database connection and successfully run sql query statement?

1

1 Answers

5
votes

You should get rid of ojdbc14.jar and jdbc5.jar. The first one is intended for Java 1.4, the second one is intended for Java 5 (unless you actually use these outdated, non-supported Java versions).

If you are using Java7 then you should use ojdbc7.jar. If you are still using the (un-supported) Java 6, you should use ojdbc6.jar.

Note that the number in the file name only denotes the Java version, not the driver's version. To get that you would need to look at the MANIFEST.MF or use DatabaseMetaData.getDriverVersion()

Regarding the class loading in Tomcat:

Tomcat loads classes from either $CATALINA_HOME/lib, $CATALINA_HOME/lib/ext or in one of the deployed webbaps in the WEB-INF/lib directory.

So in your case, the outdated, obsolete /somepath/tomcat/webapps/bob/WEB-INF/lib/ojdbc14.jar is being used.

You should replace with an up-to-date version.