views:

5429

answers:

5

Hello, I've got a problem with JDBC.

I'have the following code:

//blargeparam is a blob column.
PreparedStatement pst =connection.prepareStatement("update gcp_processparams_log set blargeparam= ? where idprocessparamslog=1");

pst.setBinaryStream(1,inputStream);

I get the following error:

Exception in thread "main" java.lang.AbstractMethodError:           
oracle.jdbc.driver.T2CPreparedStatement.setBinaryStream(ILjava/io/InputStream;)V

My connection string is "jdbc:oracle:oci:@....."

The oracle version is 11g.

From the error message it seems that something is missing but:

  • when I read from the same blob column (with blob.getBytes) everything works.
  • The dll's of the instant client are (correctly) in the library path.
  • This is the manifest of the oracle jdbc jar in my class path:

    Manifest-Version: 1.0
    Specification-Title: Oracle JDBC driver classes for use with JDK14
    Sealed: true
    Created-By: 1.4.2_14 (Sun Microsystems Inc.)
    Implementation-Title: ojdbc14.jar
    Specification-Vendor: Oracle Corporation
    Specification-Version: Oracle JDBC Driver version - "10.2.0.4.0"
    Implementation-Version: Oracle JDBC Driver version - "10.2.0.4.0"
    Implementation-Vendor: Oracle Corporation
    Implementation-Time: Sat Feb 2 11:40:29 2008

+2  A: 

Here's what the JDK API says about AbstractMethodError:

Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.

Bug in the oracle driver, maybe?

Steve B.
Yes, the error terminates the JVM so it's very important to know what is causing it! As soon as I can (tomorrow) I will check if downloading the latest version of the client helps. The other thing that comes to my mind is that there is some dll conflict with a oracle client on my machine.
mic.sca
+1  A: 

I would suggest investigating your classpath very carefully. You might have two different versions of a jar file where one invokes methods in the other and the other method is abstract.

Thorbjørn Ravn Andersen
+2  A: 

With JDBC, that error usually occurs because your JDBC driver implements an older version of the JDBC API than the one included in your JRE. These older versions are fine so long as you don't try and use a method that appeared in the newer API.

I'm not sure what version of JDBC setBinaryStream appeared in. It's been around for a while, I think.

Regardless, your JDBC driver version (10.2.0.4.0) is quite old, I recommend upgrading it to the version that was released with 11g (down here), and try again.

skaffman
I've updated the oracle client jdbc driver and dlls to the latest version and everything works fine. (note that I'm running on jre 6).I'm still puzzled however.
mic.sca
It's simple enough... your driver did not support the version of the API you were using. The new one does.
skaffman
A: 

It looks that even if the driver 10.2 is compatible with the JDBC3 it may not work with JRE6 as I've found here:

http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#02_03

Which JDBC drivers support which versions of Javasoft's JDK?

pre-8i OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
8.1.5 OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
8.1.6SDK THIN Driver - JDK 1.1.x and JDK 1.2.x (aka Java2)
8.1.6SDK OCI Driver - Only JDK 1.1.x
8.1.6 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
8.1.7 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
9.0.1 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x and JDK 1.3.x
9.2.0 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
10.1.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
10.2.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, JDK 1.4.x, and JDK 5.0.x
11.1.0 OCI and THIN Driver - JDK 1.5.x and JDK 1.6.x

Oracle 10.2.0 supports:

Full support for JDBC 3.0
Note that there is no real change in the support for the following in the database. Allthat has changed is that some methods that previously threw SQLException now do something more reasonable instead.
result-set holdability
returning multiple result-sets.

mic.sca
So use the 11g drivers... you said you tried them and it worked, so what's the problem?
skaffman
Yep, the problem doesn't exist anymore. I just wanted to figure out what was happening.
mic.sca
A: 

As described in the API of java.sql.PreparedStatement.setBinaryStream() it is available since 1.6 so it is a JDBC 4.0 API! You use a JDBC 3 Driver so this method is not available!

Arne Burmeister
That's wrong, setBinaryStream is available in 1.4.2 as well and also the JDBC 3.0 spec goes: "The setBinaryStream and setObject methods may also be used to set a Blob object as a parameter in a PreparedStatement object. The setAsciiStream, setCharacterStream, and setObject methods are alternate means of setting a Clob object as a parameter."
mic.sca
No, only setBinaryStream(int parameterIndex, InputStream x, int length) has been available in JDBC 3, not setBinaryStream(int parameterIndex, InputStream x)!
Arne Burmeister
You are right. And thank you for pointing this out, I've checked this, but setBinaryStream(int parameterIndex, InputStream x, int length) gives me the same error.
mic.sca