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

org.sfm.jdbc.impl.JdbcMapperHelper Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 1.10.3
Show newest version
package org.sfm.jdbc.impl;


import org.sfm.jdbc.JdbcMapper;
import org.sfm.map.MappingContext;
import org.sfm.map.RowHandlerErrorHandler;
import org.sfm.utils.RowHandler;

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

public class JdbcMapperHelper {
    public static , T> H forEach(ResultSet rs,
                                                                 H handler,
                                                                 MappingContext context,
                                                                 JdbcMapper mapper,
                                                                 RowHandlerErrorHandler errorHandler) throws SQLException {
        while(rs.next()) {
            T t = mapper.map(rs, context);
            try {
                handler.handle(t);
            } catch(Throwable error) {
                errorHandler.handlerError(error, t);
            }
        }
        return handler;

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy