sql

igrishaev 2026-03-17T18:19:09.439499Z

In next.jdbc, is it possible to reproduce the following piece of code?

try (Statement stmt = conn.createStatement();
     ResultSet rs = stmt.executeQuery("SELECT my_bits FROM my_table")) {
    if (rs.next()) {
        java.util.BitSet bitSet = rs.getObject("my_bits", java.util.BitSet.class);
        //                                                ^^^^^^^^^^^^^^^^^^^^^^^
    }
} catch (Exception e) {
    e.printStackTrace();
}
The main point is a custom class which is passed into the getObject method. I'd like to handle bit strings as a BitSet. Without it, the column comes as a plain string with 0 and 1 characters

seancorfield 2026-03-17T18:36:17.498429Z

If there's a specific java.sql.<Type> for the DB column, you can extend ReadableColumn to that type, but that's global for your app (since it's a protocol).

seancorfield 2026-03-17T18:37:32.268109Z

The alternative is the builder-adapter which can take a custom column reader for a specific query / result set.

seancorfield 2026-03-17T18:37:45.925599Z

The Tips &amp; Tricks page has examples of both.

seancorfield 2026-03-17T18:38:59.228069Z

(the in-progress next version allows for an optimized builder-adapter that can pre-build the column reader functions once per result set, rather than running that selection logic on every column of every row)

seancorfield 2026-03-17T18:49:10.796039Z

Does that help at all @igrishaev?

igrishaev 2026-03-17T18:50:10.379789Z

Yeah that's definitely something to experiment with, thanks a lot!