How to register oracle jdbc driver on Tomcat 7.0.47 startup?
driver, java, jdbc, oracle, tomcat
Solution
Can you clarify what you mean by "lib folder in the tomcat installation folder"? It should mean the /lib directly under your Tomcat root.
The Tomcat 7 docs say this:
Thus, the web applications that have database drivers in their WEB-INF/lib directory cannot rely on the service provider mechanism and should register the drivers explicitly.
The right thing to do is to set up a JNDI data source rather than creating one in your code using DriverManager.
I'd also recommend matching the driver version to both your Oracle and JVM versions. JDK 6 has reached the end of its support life. JDK 7 is current production. I'd recommend upgrading from ojdbc6.jar if you're using JDK 7.
Problem
I copied ojdbc6.jar to the lib folder in the tomcat installation folder. When I deploy my Web App which makes use of the Oracle Driver in a JDBC Connection, the server says that the driver class can't be found, and I am forced to do DriverManager.registerDriver manually, then it works. Can it be done so the driver is registered at startup and I don't have to do it manually neither create a connection pool?