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

The following are Jave code examples for showing how to use equals() of the java.sql.Connection class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: DataSourceUtils.java   View Source Code Vote up 5 votes
/**
 * 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));
}