All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.sylinx.hbatis.kit.DbKit Maven / Gradle / Ivy

The newest version!
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);
			}
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy