sql

All things SQL and JDBC...
v3ga 2021-06-10T03:37:51.180300Z

Ok, I’ll take a look.

orestis 2021-06-10T06:03:13.181200Z

Would a vector of numbers be interpreted as a function call? Or is it keyword/symbol first element?

seancorfield 2021-06-10T06:27:18.181400Z

The numbers would be treated as parameters and the vector would be rendered as a SQL tuple β€” but it would still be wrong πŸ™‚

mccraigmccraig 2021-06-10T14:56:17.184600Z

i'm using next.jdbc with hikari and postgres and i'm having what looks like some timezone related problems - is there any way to set the connection timezone for connections gotten via the pool ? HikariConfig.setConnectionInitSql seems ideal, but i'm not even creating a HikariConfig object, just (connection/->pool HikariDataSource db-spec)

camsaul 2021-06-11T21:30:12.186100Z

@mccraigmccraig for Postgres you can always just .execute

SET SESSION TIMEZONE TO 'US/Pacific';
You could wrap the DataSource you pass to Hikari and have it do that in getConnection when it creates new connections to add to the pool

camsaul 2021-06-11T21:32:44.186400Z

e.g. something like

(defn wrapped-data-source ^javax.sql.DataSource [^javax.sql.DataSource original-data-source]
  (reify javax.sql.DataSource
    (getConnection [_]
      (let [conn (.getConnection original-data-source)]
        (try
          (with-open [stmt (.createStatement conn)]
            (.executeUpdate stmt "SET SESSION TIME ZONE 'US/Pacific';"))
          (catch Throwable e
            (.close conn)
            (throw e)))
        conn))))

camsaul 2021-06-11T21:44:41.186900Z

that works for me locally with Postgres + C3P0 at least.

πŸ‘ 1
mccraigmccraig 2021-06-13T20:33:30.195200Z

good idea, thanks @camsaul

mccraigmccraig 2021-06-10T15:52:43.184700Z

given up, just forced the JVM to UTC, which matches all our production stuff anyway

seancorfield 2021-06-10T16:33:29.185Z

See https://github.com/seancorfield/next-jdbc/issues/138 β€” that’s why jdbc-url got added (but there’s a bug affecting SQL Server usage right now β€” already fixed on develop but not released).

mccraigmccraig 2021-06-10T16:39:52.185300Z

ah, ok, that makes sense

seancorfield 2021-06-10T16:43:05.185500Z

HikariCP has some weird blind spots. Like: using username instead of user β€” even though all the JDBC drivers use user 😐

seancorfield 2021-06-10T16:43:20.185700Z

(and c3p0 uses user)

mccraigmccraig 2021-06-10T17:17:42.185900Z

πŸ‘ thanks @seancorfield