⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resultreader.java

📁 一个Java持久层类库
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package ActiveObject.core;import java.sql.*;/** * @author tanjiazhang */public class ResultReader {    private Connection connection = null;    private PreparedStatement preparedStatement = null;    private ResultSet resultSet = null;    public ResultReader(String sql, Object... params) throws java.sql.SQLException    {        this.connection = ActiveRecord.getConnection();        this.preparedStatement = connection.prepareStatement(sql);        int index = 1;        for(Object value : params)            preparedStatement.setObject(index, value);        this.resultSet = preparedStatement.executeQuery();    }    /**     * 尝试读一行记录,只有返回值为真时,才允许取出该对象     * @throws java.sql.SQLException     */    public boolean read () throws java.sql.SQLException {        return this.resultSet.next();    }    /**     * 尝试读一行记录,只有返回值为真时,才允许取出该对象     * @throws java.sql.SQLException     */    public ResultSet getResultSet () throws java.sql.SQLException {        return this.resultSet;    }    /**     * 使用DataReader完毕后必须执行close释放资源     * @throws java.sql.SQLException     */    public void close () throws java.sql.SQLException {        this.resultSet.close();        this.preparedStatement.close();        this.connection.close();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -