sql

István Karaszi 2026-03-27T10:59:03.381179Z

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

✅ 1
István Karaszi 2026-03-27T10:59:58.074239Z

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

p-himik 2026-03-27T11:09:00.274739Z

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
$$;

István Karaszi 2026-03-27T11:09:11.008579Z

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

p-himik 2026-03-27T11:11:07.903419Z

What about an explicit transaction? Does JDBC complain?

BEGIN TRANSACTION;
...
COMMIT;

István Karaszi 2026-03-27T11:11:59.471249Z

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

István Karaszi 2026-03-27T11:13:50.581879Z

Well, it might work

István Karaszi 2026-03-27T11:14:22.007989Z

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

István Karaszi 2026-03-27T11:40:17.078999Z

Thank you!

👍 1