YCSB JDBS驱动程序:Java.lang.ClassNotFoundException



在尝试将数据加载到mysql时,我会得到以下错误:

    ~/YCSB$ bin/ycsb load jdbc -P workloads/workloada -P db.properties
[WARN] Running against a source checkout. In order to get our runtime dependencies we'll have to invoke Maven. Depending on the state of your system, this may take ~30-45 seconds
[DEBUG] Running 'mvn -pl com.yahoo.ycsb:jdbc-binding -am package -DskipTests dependency:build-classpath -DincludeScope=compile -Dmdep.outputFilterFile=true'
/usr/lib/jvm/java-8-oracle/bin/java -cp /home/zakaria/YCSB/jdbc/conf:/home/zakaria/YCSB/jdbc/target/jdbc-binding-0.14.0-SNAPSHOT.jar:/home/zakaria/.m2/repository/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1/geronimo-jta_1.1_spec-1.1.1.jar:/home/zakaria/.m2/repository/org/apache/htrace/htrace-core4/4.1.0-incubating/htrace-core4-4.1.0-incubating.jar:/home/zakaria/.m2/repository/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar:/home/zakaria/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.4/HdrHistogram-2.1.4.jar:/home/zakaria/.m2/repository/org/apache/openjpa/openjpa-jdbc/2.1.1/openjpa-jdbc-2.1.1.jar:/home/zakaria/.m2/repository/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar:/home/zakaria/.m2/repository/org/apache/openjpa/openjpa-kernel/2.1.1/openjpa-kernel-2.1.1.jar:/home/zakaria/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.4/jackson-core-asl-1.9.4.jar:/home/zakaria/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/zakaria/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:/home/zakaria/YCSB/core/target/core-0.14.0-SNAPSHOT.jar:/home/zakaria/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.4/jackson-mapper-asl-1.9.4.jar:/home/zakaria/.m2/repository/org/apache/openjpa/openjpa-lib/2.1.1/openjpa-lib-2.1.1.jar:/home/zakaria/.m2/repository/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar com.yahoo.ycsb.Client -db com.yahoo.ycsb.db.JdbcDBClient -P workloads/workloada -P db.properties -load
Command line: -db com.yahoo.ycsb.db.JdbcDBClient -P workloads/workloada -P db.properties -loadYCSB Client 0.14.0-SNAPSHOT
Loading workload...
Starting test.
Error in initializing the JDBS driver: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver  # The JDBC driver class to use.
com.yahoo.ycsb.DBException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver # The JDBC driver class to use.
at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:220)
at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:86)
at com.yahoo.ycsb.ClientThread.run(Client.java:423)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver  # The JDBC driver class to use.
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:194)
... 3 more
com.yahoo.ycsb.DBException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver # The JDBC driver class to use.
at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:220)
at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:86)
at com.yahoo.ycsb.ClientThread.run(Client.java:423)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver  # The JDBC driver class to use.
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:194)
... 3 more
[OVERALL], RunTime(ms), 5
[OVERALL], Throughput(ops/sec), 0.0
[TOTAL_GCS_PS_Scavenge], Count, 0
[TOTAL_GC_TIME_PS_Scavenge], Time(ms), 0
[TOTAL_GC_TIME_%PS_Scavenge], Time(%), 0.0
[TOTAL_GCS_PS_MarkSweep], Count, 0
[TOTAL_GC_TIME_PS_MarkSweep], Time(ms), 0
[TOTAL_GC_TIME%PS_MarkSweep], Time(%), 0.0
[TOTAL_GCs], Count, 0
[TOTAL_GC_TIME], Time(ms), 0
[TOTAL_GC_TIME%], Time(%), 0.0

我设置了我的db.properties(in〜/ycsb文件夹(,如下:

db.driver=com.mysql.jdbc.Driver # The JDBC driver class to use.
db.url=jdbc:mysql://master:3306/ycsb # The Database connection URL.
db.user=root # User name for the connection.
db.passwd=

我已经在"〜/ycsb/jdbc"中创建了lib文件夹,并将" mysql-connector-java-java-5.1.46-bin.jar"放在那里。

您认为是评论,不是。在属性文件中,#仅表示注释,如果它是行上的第一个非Whitespace字符。

来自Properties.load(Reader)

评论行的ASCII '#''!'是其第一个非白色空间字符;

错误消息包含注释的事实证明了这一点:

java.lang.classnotfoundexception:com.mysql.jdbc.driver ##要使用的JDBC驱动程序类。

换句话说,更改

db.driver=com.mysql.jdbc.Driver # The JDBC driver class to use.
db.url=jdbc:mysql://master:3306/ycsb # The Database connection URL.
db.user=root # User name for the connection.
db.passwd=

to

# The JDBC driver class to use.
db.driver=com.mysql.jdbc.Driver 
# The Database connection URL.
db.url=jdbc:mysql://master:3306/ycsb 
# User name for the connection.
db.user=root 
db.passwd=

或完全删除注释

i通过删除注释并在pom.xml中添加以下依赖关系解决了问题

<dependency>
      <groupId>com.mysql.driver</groupId>
      <artifactId>mysqldriver</artifactId>
      <version>5.1.46</version>
      <scope>system</scope>
      <systemPath>/PATH/YCSB/jdbc/lib/mysql-connector-java-5.1.46-bin.jar</systemPath>
</dependency> 

相关内容

  • 没有找到相关文章

最新更新