本文整理汇总了Java中java.sql.Connection.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.equals方法的具体用法?Java Connection.equals怎么用?Java Connection.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.Connection
的用法示例。
在下文中一共展示了Connection.equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectionEquals
import java.sql.Connection; //导入方法依赖的package包/类
/**
* 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));
}