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:
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
This question is related to
java
database
oracle
jdbc
oracleclient
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?
The problem is due to older version of ojdbc - ojdbc14.
Place the latest version of ojdbc jar file in your application or shared library. (Only one version should be there and it should be the latest one) As of today - ojdbc6.jar
Check the application libraries and shared libraries on server.
Just put ojdbc6.jar
in class path, so that we can fix CallbaleStatement
exception:
oracle.jdbc.driver.T4CPreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V)
in Oracle.
InputStream in = new FileInputStream(file);
cstmt.setBinaryStream(1, in,file.length());
instead of this u need to use
InputStream in = new FileInputStream(file);
cstmt.setBinaryStream(1, in,(int)file.length());
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 (download here), and try again.
I got the same problem and resolved it.
To resolve this problem, you should upgrade commons-dbcp library to latest version (1.4). It will work with latest JDBC drivers.
In my case this was the error.
Exception in thread "main" java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.isValid(DelegatingConnection.java:917) at org.apache.tomcat.dbcp.dbcp2.PoolableConnection.validate(PoolableConnection.java:282) at org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:356) at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2306) at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2289) at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2038) at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1532) at beans.Test.main(Test.java:24)
Solution: I just change ojdbc14.jar
to ojdbc6.jar
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!
In my case problem was at context.xml file of my project.
The following from context.xml causes the java.lang.AbstractMethodError, since we didn't show the datasource factory.
<Resource name="jdbc/myoracle"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@(DESCRIPTION = ... "
username="****" password="****" maxActive="10" maxIdle="1"
maxWait="-1" removeAbandoned="true"/>
Simpy adding factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" solved the issue:
<Resource name="jdbc/myoracle"
auth="Container"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@(DESCRIPTION = ... "
username="****" password="****" maxActive="10" maxIdle="1"
maxWait="-1" removeAbandoned="true"/>
To make sure I reproduced the issue several times by removing factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" from Resource
I think, the reason of the error from JDBC driver, you should get suitable JDBC driver for your Oracle db. You can get it from
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
Just use ojdb6.jar and will fix all such issues.
For maven based applications:
Download and copy ojdbc6.jar to a directory in your local machine
From the location where you have copied your jar install the ojdbc6.jar in your local .M2 Repo by issuing below command C:\SRK\Softwares\Libraries>mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true
Add the below in your project pom.xml as ojdbc6.jar dependency
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
PS: The issue might be due to uses of @Lob annotation in JPA for storing large objects specifically in oracle db columns. Upgrading to 11.2.0.3 (ojdbc6.jar) can resolve the issue.
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.
I do meet this problem. use ojdbc14.jar and jdk 1.6
InputStream in = new FileInputStream(file);
cstmt.setBinaryStream(1, in,file.length()); // got AbstractMethodError
InputStream in = new FileInputStream(file);
cstmt.setBinaryStream(1, in,(int)file.length()); // no problem.
Source: Stackoverflow.com