weixin_39789979
weixin_39789979
2021-01-09 02:06

Error in database operation: java.sql.SQLException: No suitable driver found

Hello,

I am using mysql-connector-java-5.1.35 to use MySql with JDBC. I have placed mysql-connector-java-5.1.35-bin.jar in the jdbc/src/main/java/com/yahoo/ycsb/db directory of YCSB. I have changed db.properties file under conf as

jdbc.driver=com.mysql.jdbc.Driver db.url=jdbc:mysql://localhost:3306/dbname db.user=root db.passwd=

I have also placed mysql-connector-java-5.1.35-bin.jar in the CLASSPATH

I have run the below command and I have Driver not found Error. Can anyone help me

Command line: -db com.yahoo.ycsb.db.JdbcDBClient -threads 2 -p recordcount=500000 -P workloads/workloada -s -load Loading workload... Starting test. Adding shard node URL: Adding shard node URL: Error in database operation: java.sql.SQLException: No suitable driver found for com.yahoo.ycsb.DBException: java.sql.SQLException: No suitable driver found for at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:221) at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:63) at com.yahoo.ycsb.ClientThread.run(Client.java:197) Caused by: java.sql.SQLException: No suitable driver found for at java.sql.DriverManager.getConnection(DriverManager.java:596) at java.sql.DriverManager.getConnection(DriverManager.java:215) at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:201) ... 2 more com.yahoo.ycsb.DBException: java.sql.SQLException: No suitable driver found for at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:221) at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:63) at com.yahoo.ycsb.ClientThread.run(Client.java:197) Caused by: java.sql.SQLException: No suitable driver found for Error in database operation: java.sql.SQLException: No suitable driver found for com.yahoo.ycsb.DBException: java.sql.SQLException: No suitable driver found for at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:221) at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:63) at com.yahoo.ycsb.ClientThread.run(Client.java:197)


at java.sql.DriverManager.getConnection(DriverManager.java:596)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:201)
... 2 more

Caused by: java.sql.SQLException: No suitable driver found for at java.sql.DriverManager.getConnection(DriverManager.java:596) at java.sql.DriverManager.getConnection(DriverManager.java:215) at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:201) ... 2 more com.yahoo.ycsb.DBException: java.sql.SQLException: No suitable driver found for at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:221) at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:63) at com.yahoo.ycsb.ClientThread.run(Client.java:197) Caused by: java.sql.SQLException: No suitable driver found for at java.sql.DriverManager.getConnection(DriverManager.java:596) at java.sql.DriverManager.getConnection(DriverManager.java:215) at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:201) ... 2 more 2015-04-25 21:39:39:572 0 sec: 0 operations; [OVERALL], RunTime(ms), 185.0 [OVERALL], Throughput(ops/sec), 0.0 2015-04-25 21:39:39:576 0 sec: 0 operations;

Thank you.

该提问来源于开源项目:brianfrankcooper/YCSB

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39951181 weixin_39951181 4月前

    Looks like a classpath issue. Double check. Normally, you want to place the jar in a directory where the run script will find it. Looks like you've checked out and are building from source. I did the same and would put the mysql jar in jdbc/target directory, right next to the jdbc-binding-0.1.4.jar.

    Chrisjan

    点赞 评论 复制链接分享
  • weixin_39789979 weixin_39789979 4月前

    Chrisjan,

    Now, I have placed the jar file under jdbc/target directory, added the same in the CLASSPATH. I also have sql-connector-java-5.1.35 directory under jdbc directory. Still I see the same error.

    Any idea?

    Sai

    点赞 评论 复制链接分享
  • weixin_39951181 weixin_39951181 4月前

    I just noticed in your post that you say you have your jdbc properties in a file called db.properties. I'm not certain that this file gets read by default. Try adding "-P conf/db.properties" to explicitly load this file, or type the properties in the workloada file directly, or you can pass each property on the command line like "-p jdbc.driver=com.mysql.jdbc.Driver -p db.url=jdbc:mysql://localhost:3306/dbname -p db.user=root -p db.passwd=".

    Good luck.

    点赞 评论 复制链接分享
  • weixin_39789979 weixin_39789979 4月前

    Thank you Chrisjan. Adding each property of Db driver class, JDBC url and login credentials on the command line did the trick.

    点赞 评论 复制链接分享