Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get java.lang.AbstractMethodError: oracle.jdbc.driver.OracleConnection error?

Tags:

java

oracle

jdbc

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)
like image 541
Mike Avatar asked May 20 '11 01:05

Mike


People also ask

How do I know if Oracle JDBC driver is installed?

You can determine the version of the JDBC driver that you installed, by calling the getDriverVersion method of the OracleDatabaseMetaData class. You can also determine the version of the JDBC driver by executing the following commands: java -jar ojdbc5. jar.

What is JDBC error?

JDBC connection errors. Connection errors are typically caused by incorrect or invalid connection string parameters, such as an invalid host name or database name. Verify that you are using correct and valid connection string parameters for the Gate.

What JDBC version is compatible with Oracle 19c?

As noted, ojdbc6 and 7 are both successfully used with 19c.


2 Answers

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)

like image 168
Klas Lindbäck Avatar answered Nov 15 '22 00:11

Klas Lindbäck


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.

like image 45
isapir Avatar answered Nov 14 '22 22:11

isapir