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

The following examples show how to use java.sql.Connection#getNetworkTimeout() . 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 File: ConnectionIT.java    From snowflake-jdbc with 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 File: Jdbc41Bridge.java    From Tomcat8-Source-Read with 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 File: Jdbc41Bridge.java    From commons-dbcp with 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;
    }
}