org.sfm.jdbc.impl.JdbcMapperHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
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;
}
}