sql 2026-03-27

What is the most convenient way to always execute certain statements when opening a new connection? I am using HIkariCP and next.jdbc

✅ 1

I can see that HikariCP supports connectionInitSql but that seems to support only one statement

Does providing multiple statements separated with ; not work? What about wrapping them with BEGIN; ... END; or something like that? Or, in the case of PostgreSQL, with something like

DO
$$
    BEGIN
        ...
    END
$$;

I need this with DuckDB that does not support DO $$ BEGIN $$; blocks

What about an explicit transaction? Does JDBC complain?

BEGIN TRANSACTION;
...
COMMIT;

I could not see any examples using multiple statements with HikariCP, but I’ll verify that just to make sure

Well, it might work

Since it is not complaining, and when I intentionally make a mistake in the second statement, then it throws an error

Thank you!

👍 1