Click here to Skip to main content
15,861,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to set a network time-out my Oracle database Connection in Java. However, I'm getting an error. Below is sample code and it's respective exception.
Java
try{
   conn = new Database("oracle").connect();
   conn.setNetworkTimeout(null, 30000); //I don't have an Executor, so the field is set to null
   System.out.println(Switch.date() + " -> Database Connection Initialized");
}
catch(SQLException ex){
   Logger.getLogger(Switch.class.getName()).log(Level.SEVERE, null, ex);
}

The Exception I'm getting is:
Java
Exception in thread "main" java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.setNetworkTimeout(Ljava/util/concurrent/Executor;I)V
    at ke.co.smart.Switch.<init>(Switch.java:524)
    at ke.co.smart.Switch.main(Switch.java:161)
Java Result: 1

I believe it has to do with a method being abstract (read AbstractMethodError). What could probably cause this error as I have only implemented the method which I think is already defined within Java, and thus, does not refuse to compile.

N.B. Java does not allow compilation of concrete classes if there are abstract methods.
Posted

After doing some more research on the above topic, and checking the Oracle implementation of the Java API, oracles JDBC 4.0 has not implemented the method setNetworkTimeout. That causes the error java.lang.AbstractMethodError. I think that by failing to implement all methods of the Connection interface, there are some API violations that causes the JVM to throw the indicated error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900