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

The following examples show how to use java.sql.Connection#equals() . 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Compares innermost delegate to the given connection.
 *
 * @param c
 *            connection to compare innermost delegate with
 * @return true if innermost delegate equals <code>c</code>
 */
@SuppressWarnings("resource")
public boolean innermostDelegateEquals(final Connection c) {
    final Connection innerCon = getInnermostDelegateInternal();
    if (innerCon == null) {
        return c == null;
    }
    return innerCon.equals(c);
}
 
Example 2
Source Project: spring-analysis-note   File: DataSourceUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Determine whether the given two Connections are equal, asking the target
 * Connection in case of a proxy. Used to detect equality even if the
 * user passed in a raw target Connection while the held one is a proxy.
 * @param conHolder the ConnectionHolder for the held Connection (potentially a proxy)
 * @param passedInCon the Connection passed-in by the user
 * (potentially a target Connection without proxy)
 * @return whether the given Connections are equal
 * @see #getTargetConnection
 */
private static boolean connectionEquals(ConnectionHolder conHolder, Connection passedInCon) {
	if (!conHolder.hasConnection()) {
		return false;
	}
	Connection heldCon = conHolder.getConnection();
	// Explicitly check for identity too: for Connection handles that do not implement
	// "equals" properly, such as the ones Commons DBCP exposes).
	return (heldCon == passedInCon || heldCon.equals(passedInCon) ||
			getTargetConnection(heldCon).equals(passedInCon));
}
 
Example 3
Source Project: micronaut-data   File: DataSourceUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Determine whether the given two Connections are equal, asking the target
 * Connection in case of a proxy. Used to detect equality even if the
 * user passed in a raw target Connection while the held one is a proxy.
 * @param conHolder the ConnectionHolder for the held Connection (potentially a proxy)
 * @param passedInCon the Connection passed-in by the user
 * (potentially a target Connection without proxy)
 * @return whether the given Connections are equal
 * @see #getTargetConnection
 */
private static boolean connectionEquals(ConnectionHolder conHolder, Connection passedInCon) {
    if (!conHolder.hasConnection()) {
        return false;
    }
    Connection heldCon = conHolder.getConnection();
    // Explicitly check for identity too: for Connection handles that do not implement
    // "equals" properly, such as the ones Commons DBCP exposes).
    return (heldCon == passedInCon || heldCon.equals(passedInCon) ||
            getTargetConnection(heldCon).equals(passedInCon));
}
 
Example 4
Source Project: java-technology-stack   File: DataSourceUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Determine whether the given two Connections are equal, asking the target
 * Connection in case of a proxy. Used to detect equality even if the
 * user passed in a raw target Connection while the held one is a proxy.
 * @param conHolder the ConnectionHolder for the held Connection (potentially a proxy)
 * @param passedInCon the Connection passed-in by the user
 * (potentially a target Connection without proxy)
 * @return whether the given Connections are equal
 * @see #getTargetConnection
 */
private static boolean connectionEquals(ConnectionHolder conHolder, Connection passedInCon) {
	if (!conHolder.hasConnection()) {
		return false;
	}
	Connection heldCon = conHolder.getConnection();
	// Explicitly check for identity too: for Connection handles that do not implement
	// "equals" properly, such as the ones Commons DBCP exposes).
	return (heldCon == passedInCon || heldCon.equals(passedInCon) ||
			getTargetConnection(heldCon).equals(passedInCon));
}
 
Example 5
/**
 * Determine whether the given two Connections are equal, asking the target
 * Connection in case of a proxy. Used to detect equality even if the
 * user passed in a raw target Connection while the held one is a proxy.
 * @param conHolder the ConnectionHolder for the held Connection (potentially a proxy)
 * @param passedInCon the Connection passed-in by the user
 * (potentially a target Connection without proxy)
 * @return whether the given Connections are equal
 * @see #getTargetConnection
 */
private static boolean connectionEquals(ConnectionHolder conHolder, Connection passedInCon) {
	if (!conHolder.hasConnection()) {
		return false;
	}
	Connection heldCon = conHolder.getConnection();
	// Explicitly check for identity too: for Connection handles that do not implement
	// "equals" properly, such as the ones Commons DBCP exposes).
	return (heldCon == passedInCon || heldCon.equals(passedInCon) ||
			getTargetConnection(heldCon).equals(passedInCon));
}
 
Example 6
/**
 * Determine whether the given two Connections are equal, asking the target
 * Connection in case of a proxy. Used to detect equality even if the
 * user passed in a raw target Connection while the held one is a proxy.
 * @param conHolder the ConnectionHolder for the held Connection (potentially a proxy)
 * @param passedInCon the Connection passed-in by the user
 * (potentially a target Connection without proxy)
 * @return whether the given Connections are equal
 * @see #getTargetConnection
 */
private static boolean connectionEquals(ConnectionHolder conHolder, Connection passedInCon) {
	if (!conHolder.hasConnection()) {
		return false;
	}
	Connection heldCon = conHolder.getConnection();
	// Explicitly check for identity too: for Connection handles that do not implement
	// "equals" properly, such as the ones Commons DBCP exposes).
	return (heldCon == passedInCon || heldCon.equals(passedInCon) ||
			getTargetConnection(heldCon).equals(passedInCon));
}
 
Example 7
Source Project: effectivejava   File: DataSourceUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Determine whether the given two Connections are equal, asking the target
 * Connection in case of a proxy. Used to detect equality even if the
 * user passed in a raw target Connection while the held one is a proxy.
 * @param conHolder the ConnectionHolder for the held Connection (potentially a proxy)
 * @param passedInCon the Connection passed-in by the user
 * (potentially a target Connection without proxy)
 * @return whether the given Connections are equal
 * @see #getTargetConnection
 */
private static boolean connectionEquals(ConnectionHolder conHolder, Connection passedInCon) {
	if (!conHolder.hasConnection()) {
		return false;
	}
	Connection heldCon = conHolder.getConnection();
	// Explicitly check for identity too: for Connection handles that do not implement
	// "equals" properly, such as the ones Commons DBCP exposes).
	return (heldCon == passedInCon || heldCon.equals(passedInCon) ||
			getTargetConnection(heldCon).equals(passedInCon));
}
 
Example 8
/**
 * Compares innermost delegate to the given connection.
 *
 * @param c
 *            connection to compare innermost delegate with
 * @return true if innermost delegate equals <code>c</code>
 */
@SuppressWarnings("resource")
public boolean innermostDelegateEquals(final Connection c) {
    final Connection innerCon = getInnermostDelegateInternal();
    if (innerCon == null) {
        return c == null;
    }
    return innerCon.equals(c);
}
 
Example 9
private static DatabaseTransactionInfo getConnection(ArrayList<DatabaseTransactionInfo> connections2,
    Connection con)
{
  for (DatabaseTransactionInfo info : connections2)
  {
    if (con.equals(info.getConnection())) { return info; }
  }
  return null;
}
 
Example 10
Source Project: snakerflow   File: MybatisTransaction.java    License: Apache License 2.0 4 votes vote down vote up
private boolean isConnectionTransactional() {
	Connection holdCon = (Connection)TransactionObjectHolder.get();
	return (holdCon == connection || holdCon.equals(connection));
}
 
Example 11
Source Project: mango   File: DataSourceUtils.java    License: Apache License 2.0 4 votes vote down vote up
private static boolean connectionEquals(ConnectionHolder connHolder, Connection passedInConn) {
  Connection heldConn = connHolder.getConnection();
  return heldConn == passedInConn || heldConn.equals(passedInConn);
}
 
Example 12
public boolean isOriginator(Connection con, int levelsOfRemoval)
{
  String originatorText = getOriginatorText(levelsOfRemoval + 1);
  return con.equals(getConnection()) && this.originator.equals(originatorText);
}