简体   繁体   中英

Cannot load MySQL JDBC driver

Hi have a tomcat server with a web app in that is supposed to connect to a MySQL database.

The driver is loaded when I use -verbose:class

[Loaded com.mysql.jdbc.Driver from file:/app/tomcat/8.5.4/webapps/my-app/WEB-INF/lib/mysql-connector-java-5.1.36.jar]

But for some reason it's still throwing me an exception when loading spring context:

Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:

PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.RuntimeException: Could not load class of driverClassName com.mysql.jdbc.Driver

I tried to move the connector lib file to tomcat lib folder, but it didn't change anything. I tried different versions of the connector still same issue.

I can't find out what exactly problem is without your code files: but i can guess, due to this problems it throws this kinda Exception.

Possible solution, there's some mistake in database property file. This is some property, you can check, give database name and username password according to your system. The problem occurs due to single . or , or ; too.. You can find more detail here.

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost/mydb
jdbc.username=myinfuser
jdbc.password=myinfuserpw

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM