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

me.icymint.libra.jdbc.query.AbstractQuery Maven / Gradle / Ivy

package me.icymint.libra.jdbc.query;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import me.icymint.libra.jdbc.JdbcAccessException;

/**
 * 所有查询操作父类。
 * 
 * @author Daniel Yu
 * @since 2013-3-14
 * 
 * @param 
 *            查询结果。
 * @param 

* 查询参数。 * @param * 预处理语句。 */ public abstract class AbstractQuery implements SqlQuery { /** * 创建合适的预处理语句。 * * @param conn * @param sql */ protected abstract U createStatement(Connection conn, String sql); @Override public T query(Connection conn, String sql, P p) throws JdbcAccessException { U u = this.createStatement(conn, sql); try { return this.query(u, sql, p); } finally { try { u.close(); } catch (SQLException e) { throw new JdbcAccessException(e); } } } /** * 执行预处理语句,来获取查询结果。 * * @param u * @param sql * @param p */ protected abstract T query(U u, String sql, P p); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy