我已經將我的mysql-connector-java-5.1.18-bin.jar添加到jre和jdk庫。而這裏它是:java.lang.ClassNotFoundException:com.mysql.jdbc.Driver(在jre的庫中)
C:\Windows\system32>javap java.io.Bits
Compiled from "Bits.java"
class java.io.Bits extends java.lang.Object{
java.io.Bits();
static boolean getBoolean(byte[], int);
static char getChar(byte[], int);
static short getShort(byte[], int);
static int getInt(byte[], int);
static float getFloat(byte[], int);
static long getLong(byte[], int);
static double getDouble(byte[], int);
static void putBoolean(byte[], int, boolean);
static void putChar(byte[], int, char);
static void putShort(byte[], int, short);
static void putInt(byte[], int, int);
static void putFloat(byte[], int, float);
static void putLong(byte[], int, long);
static void putDouble(byte[], int, double);
}
C:\Windows\system32>javap com.mysql.jdbc.Driver
ERROR:Could not find com.mysql.jdbc.Driver
但是,當我顯示一個直接的類路徑到同一個文件,它是好的。
C:\Windows\system32>javap -classpath "B:\Java\Tools\mysql-connector-java-5.1.18\
mysql-connector-java-5.1.18\mysql-connector-java-5.1.18-bin.jar" com.mysql.jdbc.
Driver
Compiled from "Driver.java"
public class com.mysql.jdbc.Driver extends com.mysql.jdbc.NonRegisteringDriver i
mplements java.sql.Driver{
public com.mysql.jdbc.Driver() throws java.sql.SQLException;
static {};
}
的問題我是用Thilo's answer時動態加載的驅動程序啓動。沒有IOException。但字符串Class.forName(driver).newInstance()
我有ClassNotFoundException
異常。將jar添加到jre後,沒有任何改變。那有什麼問題?