本文介绍了为什么我一直得到“java.lang.AbstractMethodError:oracle.jdbc.driver.OracleConnection”"错误?它让我疯狂。 。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经读过,下载了我能找到的所有11g jdbc驱动程序,并将它们添加为库和/或jar文件到我的NetBeans应用程序。我仍然继续得到相同的AbstractMethodError,这让我变得多了!任何指导都将非常感谢!

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();
}

错误消息:

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)


推荐答案

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

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

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

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

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

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

这篇关于为什么我一直得到“java.lang.AbstractMethodError:oracle.jdbc.driver.OracleConnection”"错误?它让我疯狂。 。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 07:18