org.infinispan.persistence.jdbc.JdbcUtil Maven / Gradle / Ivy
package org.infinispan.persistence.jdbc;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.infinispan.persistence.jdbc.logging.Log;
import org.infinispan.util.logging.LogFactory;
/**
* Contains common methods used by JDBC CacheStores.
*
* @author [email protected]
*/
public class JdbcUtil {
private static final Log log = LogFactory.getLog(JdbcUtil.class, Log.class);
public static void safeClose(Statement ps) {
if (ps != null) {
try {
ps.close();
} catch (SQLException e) {
log.sqlFailureUnexpected(e);
}
}
}
public static void safeClose(Connection connection) {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
log.sqlFailureClosingConnection(connection, e);
}
}
}
public static void safeClose(ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
log.sqlFailureUnexpected(e);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy