In this library I tried to find a minimal abstraction for the standard Java JDBC framework. Overwhelmed by the complexity of the existing OR-mapping frameworks, I was searching for a library, which doesn’t try to hide SQL from the developer. But still gives you enough support by handling the tedious parts of JDBC. With a background in the Scala/Play development, I’d enjoyed using the Scala Anorm library. Unfortunately I couldn’t find a similar library for Java. So, I decided to implement one myself.

This blog gives you an overview over the usage of the FacileJDBC library, mainly by example. A detailed description of the API is available as Javadoc and the library itself is available on Maven Central. The source code can be downloaded from GitHub.

Overview

FacileJDBC gives you

  • A lightweight wrapper around the JDBC API.
  • The possibility to fill query parameters by name instead of its position: Available via the Param interface.
  • Functions for creating (parsing) entity objects from query ResultSets: Available via the RowParser interface
  • Functions for splitting (deconstructing) entity objects to DB columns: Available via the Dctor interface.
  • Query object to putting all things together.
  • Lightweight transaction handling support.

FacileJDBC is not

  • An OR-Mapper
  • A type safe query language
  • An SQL query builder

FacileJDBC has no

  • DB-vendor specific code, uses 100% pure JDBC.
  • Query generation capabilities. The user is responsible for creating the proper SQL string.
  • Generated classes or dynamically generated proxies.
  • No connection pooling.

Other Java DB libraries

  • jOOQ: Excellent library for accessing databases in a type safe way. Because of the different scope, it is more than a thin wrapper around the JDBC API.
  • Jdbi: Similar scope, but with a different approach.

#functional #jdbc #java11 #java #database

FacileJDBC
2.00 GEEK