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

me.xethh.libs.toolkits.sql.ResultSetIterator Maven / Gradle / Ivy

The newest version!
package me.xethh.libs.toolkits.sql;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;

public class ResultSetIterator implements Iterator {
    private ResultSet resultSet;
    public ResultSetIterator(ResultSet resultSet){
        this.resultSet = resultSet;
    }
    private boolean clearBit = true;
    private boolean hasNext = false;
    @Override
    public boolean hasNext() {
        try {
            if(clearBit){
                hasNext = resultSet.next();
                clearBit = false;
            }
            return hasNext;
        } catch (SQLException e) {
            e.printStackTrace();
            throw new RuntimeException("Error while extract next: "+e.getMessage(),e);
        }
    }

    @Override
    public ResultSet next() {
        if(clearBit)
            hasNext();
        clearBit = true;
        return resultSet;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy