No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

JDBJ is a small jdbc fluent interface for capturing query intent before query execution.

Primary Features

  • Named Parameters (No Positional Parameters, ever)
  • Collections bindable (not during batch execution)
  • Null-Safe fetching of (Boolean|Byte|Double|Float|Integer|Long|Short)
  • Lambda interface for bindings, transactions
  • Fetch-forward read-only cursors, always
  • Script Execution, with parameters
  • Comprehensive test suites for latest postgres, h2, derby, SQLite, MySql

Sample Code

Insert inside a transaction:

//INSERT some students
final List<NewStudent> newStudents = Arrays.asList(
        new NewStudent("Ada", "Lovelace", new BigDecimal("4.00")),
        new NewStudent("Haskell", "Curry", new BigDecimal("4.00"))

//NewStudent.INSERT is the resource which contains our sql statement
final ExecuteInsert<Long> insert = JDBJ.resource("student_insert.sql")

//db is a javax.sql.DataSource
List<Long> generatedKeys = JDBJ.transaction(connection -> {
    final List<Long> keys = new ArrayList<>();
    for (NewStudent newStudent : newStudents) {
    return keys;

Select to list:

//setup query object
final MapQuery<Student> studentsByIds = JDBJ.resource("student_by_ids_limit.sql")
        .bindLong(":limit", 10L)
        .bindLongs(":ids", generatedKeys)

//get as list
final ExecuteQuery<List<Student>> listQuery = studentsByIds

Select to stream:

//get as stream
final StreamQuery<Student> streamQuery = studentsByIds
try (Stream<Student> stream = streamQuery.execute(db)) {


A full set of examples is being developed in the examples-branch, but here are some quick examples maintained in the test directory: