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

The following examples show how to use java.sql.Connection#abort() . 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: LoadBalancedConnectionProxy.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
Source File: LoadBalancedConnectionProxy.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 File: MySqlClient.java    From presto with 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 File: ConnectionIT.java    From snowflake-jdbc with 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 File: Jdbc41Bridge.java    From Tomcat8-Source-Read with 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 File: Jdbc41Bridge.java    From commons-dbcp with 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();
    }
}