List of usage examples for java.sql Connection isClosed
boolean isClosed() throws SQLException;
Connection
object has been closed. From source file:org.sakaiproject.oaai.dao.Db.java
private void returnConnection(Connection connection) { try {// w w w . ja v a 2s . c om if (connection != null && !connection.isClosed()) { sqlService.returnConnection(connection); } } catch (Exception e) { log.error("Error returning connection to pool: " + e, e); } }
From source file:kenh.xscript.database.elements.Commit.java
public void process(@Attribute(ATTRIBUTE_REF) java.sql.Connection conn) throws UnsupportedScriptException { try {//ww w.j a va2s . c o m if (!conn.isClosed()) { if (!conn.getAutoCommit()) conn.commit(); } } catch (Exception e) { throw new UnsupportedScriptException(this, e); } }
From source file:org.alinous.plugin.mysql.MySQLConnectionFactory.java
@Override public boolean validateObject(Object obj) { Connection con = (Connection) obj; try {//from w w w. j a va 2s . com return !con.isClosed(); } catch (SQLException e) { e.printStackTrace(); return false; } }
From source file:com.liusoft.dlog4j.db.DataSourceConnectionProvider.java
public void closeConnection(Connection conn) throws SQLException { if (conn != null && !conn.isClosed()) conn.close();//from w w w . j av a 2 s . c o m }
From source file:cn.edu.seu.cose.jellyjolly.model.dao.jdbc.mysql.MysqlConnectionFactory.java
@Override public void closeConnection(Connection connection) throws JdbcDataAccessException { try {/*w w w .j ava 2s . com*/ if (connection != null && !connection.isClosed()) { connection.close(); } } catch (SQLException ex) { throw new JdbcDataAccessException(ex); } }
From source file:org.mot.common.db.DatabaseConnectionFactory.java
public boolean isConnected(Connection connection) { boolean ret = false; try {/*from w w w .j a v a 2s. co m*/ ret = !connection.isClosed(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ret; }
From source file:org.sakaiproject.lap.dao.Database.java
/** * Returns the borrowed connection to the pool * /*from w ww . j a v a 2s .c o m*/ * @param connection the connection object */ private void returnConnection(Connection connection) { try { if (connection != null && !connection.isClosed()) { sqlService.returnConnection(connection); } } catch (Exception e) { log.error("Error returning connection to pool: " + e, e); } }
From source file:org.apache.phoenix.pig.hadoop.PhoenixOutputCommitter.java
/** * Commit a transaction on task completion * //from w ww . j a v a 2 s.co m * @param connection * @throws IOException */ private void commit(Connection connection) throws IOException { try { if (connection == null || connection.isClosed()) { throw new IOException("Trying to commit a connection that is null or closed: " + connection); } } catch (SQLException e) { throw new IOException("Exception calling isClosed on connection", e); } try { LOG.debug("Commit called on task completion"); connection.commit(); } catch (SQLException e) { throw new IOException("Exception while trying to commit a connection. ", e); } finally { try { LOG.debug("Closing connection to database on task completion"); connection.close(); } catch (SQLException e) { LOG.warn("Exception while trying to close database connection", e); } } }
From source file:org.okinawaopenlabs.orientdb.client.ConnectionManagerJdbc.java
/** * close database/*www. j ava2s . c o m*/ * * @param database */ synchronized public void close(Connection conn) throws SQLException { if (conn != null && !conn.isClosed()) { DbUtils.close(conn); } }
From source file:org.apache.openejb.resource.jdbc.DbcpNPEXAConnectionTest.java
@Test public void check() throws SQLException { final Connection con = ejb.newConn(); con.close(); // no NPE Assert.assertTrue("Connection was not closed", con.isClosed()); final GenericObjectPool<PoolableConnection> pool = GenericObjectPool.class .cast(Reflections.get(ds, "connectionPool")); assertEquals(0, pool.getNumActive()); }