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

org.simpleflatmapper.jdbc.README.md Maven / Gradle / Ivy

Go to download

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

The newest version!
JdbcMapper
---------

```java

public class MyDao {
    private final JdbcMapper parameterGetterMap =
        JdbcMapperFactory.newInstance().newMapper(MyObject.class);
    public void printAllLambda(Writer writer, Connection conn) throws SQLException {
        try (PreparedStatement ps =
                conn.prepareStatement("select id, email, my_property from MyTable");
                ResultSet rs = ps.executeQuery()) {
            parameterGetterMap.forEach(rs, (o) -> writer.append(o.toString()).append("\n"));
        }
    }
    public void printAll(Writer writer, Connection conn) throws SQLException {
        try (PreparedStatement ps =
                conn.prepareStatement("select id, email, my_property from MyTable");
                ResultSet rs = ps.executeQuery()) {
            parameterGetterMap.forEach(rs, new CheckedConsumer{
                public void handle(MyObject o) throws IOException {
                    writer.append(o.toString()).append("\n");
                }
            });
        }
    }
}
```






© 2015 - 2024 Weber Informatics LLC | Privacy Policy