List of usage examples for java.sql Connection equals
public boolean equals(Object obj)
From source file:org.cfr.capsicum.datasource.DataSourceUtils.java
/** * 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//from w w w . j a va 2s .co m */ private static boolean connectionEquals(CayenneConnectionHolder 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); }
From source file:com.adaptris.core.services.jdbc.JdbcDataCaptureServiceImpl.java
protected DatabaseActor configureActor(AdaptrisMessage msg) throws SQLException { Connection c = getConnection(msg); if (!c.equals(actor.getSqlConnection())) { actor.reInitialise(c);/* w ww. j av a 2s . c om*/ } return actor; }
From source file:com.adaptris.core.services.jdbc.JdbcDataQueryService.java
/** * The main service method, which sees the specified query executed and the results returned in an XML message. * /*from w w w.j a v a2 s . co m*/ * @see com.adaptris.core.Service#doService(com.adaptris.core.AdaptrisMessage) */ @Override public void doService(AdaptrisMessage msg) throws ServiceException { log.trace("Beginning doService"); JdbcResult result = null; Connection conn = null; try { Connection c = getConnection(msg); if (!c.equals(actor.getSqlConnection())) { actor.reInitialise(c); } conn = actor.getSqlConnection(); initXmlHelper(msg); String statement = getStatementCreator().createStatement(msg); PreparedStatement preparedStatement = actor.getQueryStatement(statement); preparedStatement.clearParameters(); log.trace("Executing statement [{}]", statement); this.getParameterApplicator().applyStatementParameters(msg, preparedStatement, getStatementParameters(), statement); try { // closed by the finally block which closes the JdbcResult ResultSet rs = preparedStatement.executeQuery(); // lgtm [java/database-resource-leak] result = new JdbcResultBuilder().setHasResultSet(true).setResultSet(rs).build(); } catch (SQLException e) { if (ignoreExecuteQueryErrors()) { log.debug("Ignore ExecuteQuery Errors enabled); using empty ResultSet"); result = new JdbcResultBuilder().setHasResultSet(false).build(); } else { throw e; } } resultSetTranslator.translate(result, msg); destroyXmlHelper(msg); commit(conn, msg); } catch (Exception e) { rollback(conn, msg); throw ExceptionHelper.wrapServiceException(e); } finally { JdbcUtil.closeQuietly(result); JdbcUtil.closeQuietly(conn); } }
From source file:org.nuxeo.runtime.datasource.PatchedPoolableManagedConnection.java
@Override public boolean equals(Object obj) { if (obj == null) { return false; }/*from ww w.j av a 2 s. c o m*/ if (obj == this) { return true; } Connection delegate = getInnermostDelegateInternal(); if (delegate == null) { return false; } if (obj instanceof DelegatingConnection) { DelegatingConnection c = (DelegatingConnection) obj; return c.innermostDelegateEquals(delegate); } else { // PATCH: check object equality first return delegate == obj || delegate.equals(obj); } }
From source file:org.opoo.oqs.spring.jdbc.TransactionSupportConnectionManager.java
public void releaseConnection(Connection con) { if (dataSource == null) { throw new IllegalArgumentException("No DataSource specified"); }/*from w w w . j av a 2s . c o m*/ Connection conn = (Connection) TransactionSynchronizationManager.getResource(dataSource); if (conn != null && (con == conn || conn.equals(con))) { log.debug("Connection in Transaction, do not close."); } else { JdbcUtils.closeConnection(con); } }
From source file:org.snaker.engine.access.mybatis.MybatisTransaction.java
private boolean isConnectionTransactional() { Connection holdCon = (Connection) TransactionObjectHolder.get(); return (holdCon == connection || holdCon.equals(connection)); }
From source file:org.springframework.jdbc.datasource.DataSourceUtils.java
/** * 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//from ww w . j a v a2 s .c o m */ 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)); }