Fluent JDBC Wrapper
JdbcSession
is a convenient fluent wrapper around JDBC. Read this blog post: Fluent JDBC Decorator.
import com.jcabi.jdbc.JdbcSession; public class Main { public static void main(String[] args) throws SQLException { String name = new JdbcSession(source) .sql("SELECT name FROM foo WHERE id = ?") .set(123) .select(new SingleOutcome<String>(String.class)); } }
The only dependency you need is (you can also download jcabi-jdbc-0.19.0.jar and add it to the classpath):
<dependency> <groupId>com.jcabi</groupId> <artifactId>jcabi-jdbc</artifactId> <version>0.19.0</version> </dependency>
Similar solutions (if you know others please submit it to github): ollin, JDBI, Spring JdbcTemplate.
Cutting Edge Version
If you want to use current version of the product, you can do it with this configuration in your pom.xml
:
<repositories> <repository> <id>oss.sonatype.org</id> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.jcabi</groupId> <artifactId>jcabi-jdbc</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies>