Mysql JDBC driver ClassNotFoundException

后端 未结 3 2025
陌清茗
陌清茗 2020-12-12 05:29

I can\'t register Mysql JDBC driver in my desktop APP

I download mysql-connector-java-5.1.16.zip

Unzip mysql-connector-java-5.1.16-bin.jar a

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-12 05:54

    In your lib directory,

    1. Right click the jar file that contains your driver.
    2. The go to Build-Path
    3. Choose Add to build path
    4. Run your code again

    Also, if you are running JDBC 4.0 compatible driver you no longer need to automatically load your driver. According to JDBC 4.0 specification, section 3.1 under Automatic loading of java.sql.Driver says

    DriverManager.getConnection has been modified to utilize the Java SE Service Provider mechanism to automatically load JDBC Drivers. This removes the need to invoke Class.forName.

提交回复
热议问题