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

org.simpleflatmapper.jdbc.ResultSetEnumerable Maven / Gradle / Ivy

package org.simpleflatmapper.jdbc;

import org.simpleflatmapper.util.Enumerable;
import org.simpleflatmapper.util.ErrorHelper;

import java.sql.ResultSet;
import java.sql.SQLException;

public class ResultSetEnumerable implements Enumerable {
    private final ResultSet resultSet;
    private boolean exhausted = false;
    public ResultSetEnumerable(ResultSet resultSet) {
        this.resultSet = resultSet;
    }

    @Override
    public boolean next() {
        if (exhausted) {
            return false;
        }
        try {
            if (resultSet.next()) return true;
            else {
                exhausted = true;
                return false;
            }
        } catch(SQLException e) {
            ErrorHelper.rethrow(e);
            return false;
        }
    }

    @Override
    public ResultSet currentValue() {
        return resultSet;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy