2011-12-10 97 views
1

我想在運行時加載一個jar,在這種情況下爲ojdbc14.jar。 該jar得到正確加載,我也能夠創建一個連接到數據庫(甲骨文)。 但每當我試着做了connection.createStatement();它給了我這個異常創建聲明失敗

$Exception in thread "Thread-24" java.lang.IllegalAccessError: tried to access method oracle.jdbc.driver.OracleSql.(Loracle/jdbc/driver/DBConversion;)V from class oracle.jdbc.driver.OracleStatement at oracle.jdbc.driver.OracleStatement.(OracleStatement.java:641) at oracle.jdbc.driver.T4CStatement.(T4CStatement.java:702) at oracle.jdbc.driver.T4CDriverExtension.allocateStatement(T4CDriverExtension.java:50) at oracle.jdbc.driver.PhysicalConnection.createStatement(PhysicalConnection.java:584) at oracle.jdbc.driver.PhysicalConnection.createStatement(PhysicalConnection.java:550) at genInstaller.Controller.MetadataScriptManager.checkTableExistence(MetadataScriptManager.java:450) ... ... ...

編輯:

String dbDriverLocn = //location of ojdbc14.jar 
String strDBDriverURL = "jdbc:oracle:thin:@frewper:1521:ORCL" 
String strDBUserName = "frewper" 
String strDBUserPassword = "frewper" 

new LoadClassTest().callToLoad(dbDriverLocn); 

try 
{ 
    Class.forName("oracle.jdbc.driver.OracleDriver"); 
    Connection conn = DriverManager.getConnection(strDBDriverURL,strDBUserName,strDBUserPassword); 
    Statement st = conn.createStatement(); 
    //Exception occurs here 
} catch (SQLException e) 
{ 
    e.printStackTrace(); 
} 
+0

我的猜測!你正在使用applet。不是嗎? – adatapost

+0

其實沒有它的swing應用程序... – frewper

+0

LoadClassTest是否動態加載.jar文件? – adatapost

回答

0

嘗試使用其他jar文件進行JDBC驅動程序。