setNetworkTimeout()
was introduced in JDBC 4.1 and was not present in JDBC 4.0.
You will need ojdbc7 since JDBC 4.1 came only with Java 7 if you want to use the setNetworkTimeout()
method.
The main problem is that adding methods to interfaces in later specifications can break older versions of these interfaces with errors. One of the new features of upcoming Java 8, the default methods, hopefully will make this a little less problem.
Apparently, for Oracle, there is also a JDBC driver property that can change socket timeouts.
You can also try using this Oracle JDBC property to set the socket timeout if you are using a thin driver:
Properties props = new Properties(); props.setProperty("user", "dbuser"); props.setProperty("password", "dbpassword"); props.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CONNECT_TIMEOUT, "2000"); Connection con = DriverManager.getConnection("<JDBC connection string>", props);
source share