cn.sylinx.hbatis.kit.DbKit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hbatis-core Show documentation
Show all versions of hbatis-core Show documentation
hbatis is a simple orm framework
package cn.sylinx.hbatis.kit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import cn.sylinx.hbatis.log.GLog;
/**
* 工具类
*
* @author han
*
*/
public class DbKit {
/**
* 关闭
*
* @param aclist
* AutoCloseable list
*/
public static final void closeQuietly(AutoCloseable... aclist) {
for (AutoCloseable ac : aclist) {
if (ac != null) {
try {
ac.close();
} catch (Exception e) {
GLog.error("AutoCloseable close() error: ", e);
}
}
}
}
/**
* 关闭资源
*
* @param rs
* ResultSet object
* @param st
* Statement object
*/
public static final void closeQuietly(ResultSet rs, Statement st) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
GLog.error("ResultSet close() error: ", e);
}
}
if (st != null) {
try {
st.close();
} catch (SQLException e) {
GLog.error("Statement close() error: ", e);
}
}
}
/**
* 关闭资源
* @param st Statement object
*/
public static final void closeQuietly(Statement st) {
if (st != null) {
try {
st.close();
} catch (SQLException e) {
GLog.error("Statement close() error: ", e);
}
}
}
}