tomcat7: Could not load JDBC driver class [com.mysql.jdbc.Driver]

前端 未结 2 1233
说谎
说谎 2021-01-04 07:23

I\'ve seen several similar questions on stackoverflow, but they didn\'t solved my problem. This one is specially useful, since it points to official tomcat documentation an

2条回答
  •  伪装坚强ぢ
    2021-01-04 08:21

    Solved!

    Arturs Licis' suggestion was the key. Somehow the mysql driver had been incorrectly downloaded. It seemed a .jar file, but failed to load. Tomcat was showing just the first level of the exception:

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    [...]
    

    But when I coded a very simple helloworld with Class.forName("com.mysql.jdbc.Driver"), the following error was shown instead:

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    [...]
    Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    [...]
    

    Eureka! Opening the .jar file on WinRar shows that it can be open... but with some errors.

    Downloading the driver again did solve the problem.

    Downvote for myself :-(

提交回复
热议问题