gpt4 book ai didi

java - 创建语句失败

转载 作者:行者123 更新时间:2023-11-30 04:56:13 25 4
gpt4 key购买 nike

我正在尝试在运行时加载一个 jar,在本例中为 ojdbc14.jar。jar 被正确加载,我还能够创建到数据库(oracle)的连接。但是每当我尝试执行 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();
}

最佳答案

根据这个thread看来您已经针对旧版本的 jdbc 驱动程序进行了编译,并且在运行时尝试访问不再可见的类的方法,请参阅 Oracles Announcement: oracle.jdbc.driver package desupport .

关于java - 创建语句失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8455141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com