Example usage for java.sql Connection getNetworkTimeout

List of usage examples for java.sql Connection getNetworkTimeout

Introduction

In this page you can find the example usage for java.sql Connection getNetworkTimeout.

Prototype

int getNetworkTimeout() throws SQLException;

Source Link

Document

Retrieves the number of milliseconds the driver will wait for a database request to complete.

Usage

From source file:com.adaptris.jdbc.connection.FailoverDatasourceTest.java

@Test
public void testNetworkTimeout() throws Exception {
    Connection conn = new MyProxy();

    try {//from  w  w w.  ja  v a2s  . c  o 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);
    }
}