问题描述
我已经阅读了,下载了我能找到的所有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错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!