为什么会出现 java.lang.AbstractMethodError: oracle.jdbc.driver.OracleConnection 错误?

发布于 2024-11-08 17:55:08 字数 1577 浏览 0 评论 0原文

我已经读过 为什么在尝试在数据库中加载 blob 时会出现 java.lang.AbstractMethodError?,下载了我能找到的所有 11g jdbc 驱动程序,并将它们作为库和/或 jar 文件添加到我的NetBeans 应用程序。我仍然不断收到相同的 AbstractMethodError 错误,这让我抓狂!任何指导将不胜感激!

try {

    stmt = conn.createStatement();
    inputFileInputStream = new FileInputStream(inputBinaryFile);  

    Blob vBlob = conn.createBlob();
    BufferedImage vGImage=ImageIO.read(name);
    int offset =0;
    OutputStream out = vBlob.setBinaryStream(offset);
    ImageIO.write(vGImage, "JPG", out);
    PreparedStatement stat = conn.prepareStatement("INSERT INTO item VALUES (?,?,?,?,?)");
    stat.setString(1, itemNo);
    stat.setString(2, itemName);
    stat.setBlob(3,vBlob);
    stat.setString(4, invenType);
    stat.setDouble(5, vPrice);
    stat.executeUpdate();

} catch (IOException e) {
    System.out.println("Caught I/O Exception: (Write BLOB value - Put Method).");
    e.printStackTrace();
    throw e;
} catch (SQLException e) {
    System.out.println("Caught SQL Exception: (Write BLOB value - Put Method).");
    System.out.println("SQL:\n" + sqlText);
    e.printStackTrace();
    throw e;
}finally {
    conn.close();
}  

错误信息:

Exception in thread "main" java.lang.AbstractMethodError:                        
oracle.jdbc.driver.OracleConnection.createBlob()Ljava/sql/Blob;
    at DatabaseIO.setOracleDBBlob(DatabaseIO.java:115)
    at DatabaseIO.main(DatabaseIO.java:26)

I already read Why do I get java.lang.AbstractMethodError when trying to load a blob in the db?, downloaded all of the 11g jdbc drivers I could find, and added them as libraries and/or jar files to my NetBeans application. I still keep getting the same AbstractMethodError and it is driving me batty! Any guidance would be greatly appreciated!

try {

    stmt = conn.createStatement();
    inputFileInputStream = new FileInputStream(inputBinaryFile);  

    Blob vBlob = conn.createBlob();
    BufferedImage vGImage=ImageIO.read(name);
    int offset =0;
    OutputStream out = vBlob.setBinaryStream(offset);
    ImageIO.write(vGImage, "JPG", out);
    PreparedStatement stat = conn.prepareStatement("INSERT INTO item VALUES (?,?,?,?,?)");
    stat.setString(1, itemNo);
    stat.setString(2, itemName);
    stat.setBlob(3,vBlob);
    stat.setString(4, invenType);
    stat.setDouble(5, vPrice);
    stat.executeUpdate();

} catch (IOException e) {
    System.out.println("Caught I/O Exception: (Write BLOB value - Put Method).");
    e.printStackTrace();
    throw e;
} catch (SQLException e) {
    System.out.println("Caught SQL Exception: (Write BLOB value - Put Method).");
    System.out.println("SQL:\n" + sqlText);
    e.printStackTrace();
    throw e;
}finally {
    conn.close();
}  

The error message:

Exception in thread "main" java.lang.AbstractMethodError:                        
oracle.jdbc.driver.OracleConnection.createBlob()Ljava/sql/Blob;
    at DatabaseIO.setOracleDBBlob(DatabaseIO.java:115)
    at DatabaseIO.main(DatabaseIO.java:26)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

转身以后 2024-11-15 17:55:08

问题的原因是软件不兼容(jar 文件)。

createBlob 是一个新方法(在 java 1.6 中引入),因此较旧的驱动程序不太可能实现它。

确保您的类路径仅包含兼容的驱动程序,而不包含任何早期版本的驱动程序。 (谢谢约亨)

The cause of the problem is incompatible software (jar files).

createBlob is a new method (introduced in java 1.6), so older drivers are very unlikely to implement it.

Make sure your classpath only contains compatible drivers, and not any earlier versions of the drivers. (Thanks Jochen)

握住你手 2024-11-15 17:55:08

正如其他人所说,这是由于较旧的 Oracle JDBC 驱动程序造成的。

在我的例子中,用 ojdbc16.jar (Oracle JDBC 驱动程序 11.2.0.4.0)替换 ojdbc14.jar (Oracle JDBC 驱动程序 10.1.0.5.0)解决了这个问题。

As others have said this is due to an older Oracle JDBC driver.

In my case replacing ojdbc14.jar (Oracle JDBC driver 10.1.0.5.0) with ojdbc16.jar (Oracle JDBC driver 11.2.0.4.0) fixed the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文