![java jdbc no suitable driver found java jdbc no suitable driver found](https://i.stack.imgur.com/esTyL.png)
16:02:05.214:INFO:ssion:main: DefaultSessionIdManager workerName=node0 INFORMATION: MLog clients using java 1.4+ standard logging. 16:02:04.472:INFO::main: Logging initialized to .log.StdErrLog #sql.insert=INSERT INTO article VALUES(?, ?) #sql.create_table=CREATE TABLE article (col1 numeric(10,4) ,col2 text) #sql.select_animal=SELECT name, image, id FROM animals WHERE id = ? #sql.insert_animal=INSERT INTO animals VALUES (null, ?,?) Sql.create_table=CREATE TABLE IF NOT EXISTS animals (\ #JdbcUrl=jdbc:postgresql://localhost/test JdbcUrl=jdbc:jtds:sqlserver://localhost/test #DriverClass=.DriverĭriverClass=.SQLServerDriver #with this driver class I got DriverClass not found! #JdbcUrl=jdbc:mysql://localhost/toptech?characterEncoding=utf8 I'll propose the necessary changes for inclusion in Tomcat 6.#Backslash character at the end of line means that the command continues in the next line.
![java jdbc no suitable driver found java jdbc no suitable driver found](https://images.gutefrage.net/media/fragen/bilder/mysql-error-no-suitable-driver-found-for-jdbcmysqllocalhost3306/0_big.png)
Tomcat 7 logs a message when unregistering the JDBC driver that provides a useful clue as to what is going on. use a context listener to explicitly call DriverManager.register and deregister() init() fails when DriverManager can't find the driver No class is loaded, so no driver is registered with DriverManager The driver class is not loaded since it was loaded by the common class loader and is, therefore, still available Tomcat unregisters the JDBC driver to prevent a memory leak Tomcat spots that DriverManager has registered the JDBC driver against the webapp class loader The class is registered with DriverManager but as DriverManager uses the context class loader, it is registered against your web application The common class loader loads the class The driver class is loaded due to the Class.forName() call Your driver class is in CATALINA_HOME/lib so will be loaded by Tomcat's common class loader. The problem you are seeing is a result of where you have placed the driver class, how DriverManager works internally and what Tomcat now does to prevent memory leaks. DB connectionĬonfiguration is in /META-INF/context.xml. (ojdbc1.4.jar from Oracle 10, ojdbc6 from Oracle 11) as well as PostgreSQL.Īttached is a minimal webapp that exhibits this behavior.
Java jdbc no suitable driver found drivers#
I tested with Java 6 (1.6.0_17) and JDBC 3 and 4 Drivers for Oracle : No suitable driver found forĪt (DriverManager.java:602)Īt (DriverManager.java:185)Īt .init(DBTestServlet.java:49)Īt (GenericServlet.java:212) SEVERE: DBTestServlet: : No suitable driver found for INFO: ContextListener: contextInitialized()īut when reloading the context, I get the followingġ:56:32 PM .ApplicationContext log
![java jdbc no suitable driver found java jdbc no suitable driver found](https://i.stack.imgur.com/hfOtx.png)
![java jdbc no suitable driver found java jdbc no suitable driver found](https://i.stack.imgur.com/MmneN.png)
INFO: DBTestServlet: connect1:56:12 PM .ApplicationContext log Throw new ServletException( x.toString(), x ) Īfter starting Tomcat, I get the following expected output:ġ:56:11 PM .ApplicationContext log Log( "connection established: " + con.toString() ) Startup and does following in its init() method:Ĭon = DriverManager.getConnection( url, user, pass ) This occurs with 6.0 Trunk, built from SVN yesterday ():