List of usage examples for java.sql Connection setNetworkTimeout
void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException;
Connection
or objects created from the Connection
will wait for the database to reply to any one request. From source file:com.adaptris.jdbc.connection.FailoverDatasourceTest.java
@Test public void testNetworkTimeout() throws Exception { Connection conn = new MyProxy(); try {/*from w ww. j av a 2 s.co m*/ try { conn.getNetworkTimeout(); } catch (SQLException e) { // Feature isn't supported by Derby } try { conn.setNetworkTimeout(Executors.newSingleThreadExecutor(), 1000); } catch (SQLException e) { // Feature isn't supported by Derby } } finally { JdbcUtil.closeQuietly(conn); } }