Java Code Examples for java.sql.Connection#getNetworkTimeout()

The following examples show how to use java.sql.Connection#getNetworkTimeout() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: snowflake-jdbc   File: ConnectionIT.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNetworkTimeout() throws SQLException
{
  Connection con = getConnection();
  int millis = con.getNetworkTimeout();
  assertEquals(0, millis);
  con.setNetworkTimeout(null, 200);
  assertEquals(200, con.getNetworkTimeout());
  con.close();
}
 
Example 2
Source Project: Tomcat8-Source-Read   File: Jdbc41Bridge.java    License: MIT License 3 votes vote down vote up
/**
 * Delegates to {@link Connection#getNetworkTimeout()} without throwing a {@link AbstractMethodError}.
 * <p>
 * If the JDBC driver does not implement {@link Connection#getNetworkTimeout()}, then return 0.
 * </p>
 *
 * @param connection
 *            the receiver
 * @return See {@link Connection#getNetworkTimeout()}
 * @throws SQLException
 *             See {@link Connection#getNetworkTimeout()}
 * @see Connection#getNetworkTimeout()
 */
public static int getNetworkTimeout(final Connection connection) throws SQLException {
    try {
        return connection.getNetworkTimeout();
    } catch (final AbstractMethodError e) {
        return 0;
    }
}
 
Example 3
Source Project: commons-dbcp   File: Jdbc41Bridge.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Delegates to {@link Connection#getNetworkTimeout()} without throwing an {@link AbstractMethodError}.
 * <p>
 * If the JDBC driver does not implement {@link Connection#getNetworkTimeout()}, then return 0.
 * </p>
 *
 * @param connection
 *            the receiver
 * @return See {@link Connection#getNetworkTimeout()}
 * @throws SQLException
 *             See {@link Connection#getNetworkTimeout()}
 * @see Connection#getNetworkTimeout()
 */
public static int getNetworkTimeout(final Connection connection) throws SQLException {
    try {
        return connection.getNetworkTimeout();
    } catch (final AbstractMethodError e) {
        return 0;
    }
}