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

📄 resultsetdatalistiterator.java

📁 以前写的通用数据库接口
💻 JAVA
字号:
package util.database.datalist;import java.sql.*;/** * ResultSetDataListIterator实现了DataListIterator接口,针对ResultSet使用。 * * 功能类似于java.util.Iterator,但是返回的是数据库查询的结果。 * @author Michael Zeng * @version 1.0 September 20, 2002 */public class ResultSetDataListIterator implements DataListIterator{    private DataList dl = null;    private int currIndex = 0;    /**     * package构造函数     *     * @param dataList 需要遍历查询结果的对象     * @throws Exception     */    ResultSetDataListIterator(DataList dl) throws Exception    {        this.dl = dl;        this.dl.beforeFirst();        this.currIndex = 0;    }    /**     * 功能类似于java.util.Iterator.hasNext()     *     * @return 如果有下一个元素,返回true     * @throws Exception     */    public boolean hasNext() throws Exception    {        return dl.hasNext();    }    /**     * 功能类似于java.util.Iterator.next(),但是返回的是数据库查询的结果     * 的字段值字符串数组。     *     * @return String[] 字段值字符串数组     * @throws Exception     */    public String[] next() throws Exception    {        //注意这里currIndex++,get()之后索引加1        return dl.get(this.currIndex++);    }}

⌨️ 快捷键说明

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