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

The following examples show how to use java.sql.Connection#abort() . 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
/**
 * Aborts all live connections, using the provided Executor.
 */
@Override
synchronized void doAbort(Executor executor) {
    // close all underlying connections
    for (Connection c : this.liveConnections.values()) {
        try {
            c.abort(executor);
        } catch (SQLException e) {
        }
    }

    if (!this.isClosed) {
        if (this.connectionGroup != null) {
            this.connectionGroup.closeConnectionProxy(this);
        }
    }

    this.liveConnections.clear();
    this.connectionsToHostsMap.clear();
}
 
Example 2
/**
 * Aborts all live connections, using the provided Executor.
 */
@Override
synchronized void doAbort(Executor executor) {
    // close all underlying connections
    for (Connection c : this.liveConnections.values()) {
        try {
            c.abort(executor);
        } catch (SQLException e) {
        }
    }

    if (!this.isClosed) {
        if (this.connectionGroup != null) {
            this.connectionGroup.closeConnectionProxy(this);
        }
    }

    this.liveConnections.clear();
    this.connectionsToHostsMap.clear();
}
 
Example 3
Source Project: presto   File: MySqlClient.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void abortReadConnection(Connection connection)
        throws SQLException
{
    // Abort connection before closing. Without this, the MySQL driver
    // attempts to drain the connection by reading all the results.
    connection.abort(directExecutor());
}
 
Example 4
Source Project: snowflake-jdbc   File: ConnectionIT.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAbort() throws SQLException
{
  Connection con = getConnection();
  assertTrue(!con.isClosed());
  con.abort(null);
  assertTrue(con.isClosed());
}
 
Example 5
Source Project: Tomcat8-Source-Read   File: Jdbc41Bridge.java    License: MIT License 3 votes vote down vote up
/**
 * Delegates to {@link Connection#abort(Executor)} without throwing a {@link AbstractMethodError}.
 * <p>
 * If the JDBC driver does not implement {@link Connection#abort(Executor)}, then call {@link Connection#close()}.
 * </p>
 *
 * @param connection
 *            the receiver
 * @param executor
 *            See {@link Connection#abort(Executor)}.
 * @throws SQLException
 *             See {@link Connection#abort(Executor)}.
 * @see Connection#abort(Executor)
 */
public static void abort(final Connection connection, final Executor executor) throws SQLException {
    try {
        connection.abort(executor);
    } catch (final AbstractMethodError e) {
        connection.close();
    }
}
 
Example 6
Source Project: commons-dbcp   File: Jdbc41Bridge.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Delegates to {@link Connection#abort(Executor)} without throwing an {@link AbstractMethodError}.
 * <p>
 * If the JDBC driver does not implement {@link Connection#abort(Executor)}, then call {@link Connection#close()}.
 * </p>
 *
 * @param connection
 *            the receiver
 * @param executor
 *            See {@link Connection#abort(Executor)}.
 * @throws SQLException
 *             See {@link Connection#abort(Executor)}.
 * @see Connection#abort(Executor)
 */
public static void abort(final Connection connection, final Executor executor) throws SQLException {
    try {
        connection.abort(executor);
    } catch (final AbstractMethodError e) {
        connection.close();
    }
}