sql

genekim 2025-04-28T15:49:28.740529Z

PSA: For anyone who uses Google Cloud SQL, you will invariably get errors like this from Hikari when you suspend/resume your laptop: > (bad_certificate) Received fatal alert: bad_certificate I’ve been looking for how to fix this for a year — finally found out how to fix this. The issue is documented here: https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/issues/1558 The solution is to set the following properties, according to their README: https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/blob/main/docs/jdbc.md#refresh-strategy-for-serverless-compute > - Properties connProps = new Properties(); > - connProps.setProperty(“cloudSqlRefreshStrategy”, “lazy”); Hope this helps someone who has the same problem! And thank you @seancorfield for your amazing SQL libraries!

👍 1
genekim 2025-07-29T05:23:46.541739Z

Because I already found myself trying to puzzle this out again:

(let [secret (get-config!)
        props  (doto (java.util.Properties.)
                 (.putAll
                   {"user"             (-> secret :user)
                    "password"         (-> secret :password)
                    "socketFactory"    "com.google.cloud.sql.mysql.SocketFactory"
                    "cloudSqlInstance" (-> secret :cloud-sql-instance)
                    "cloudSqlRefreshStrategy" "lazy"}))
        ;"enableIamAuth",   "true"}))
        hconfig (doto (HikariConfig.)
                  (.setJdbcUrl (format "jdbc:mysql:///%s" (:dbname secret)))
                  (.setDataSourceProperties props)
                  (.setConnectionTimeout 10000)
                  ;; Add a simple connection test query
                  (.setConnectionTestQuery "SELECT 1"))
        pool    (HikariDataSource. hconfig)]
    (log/warn :google-cloud-sql-connect! (-> secret :cloud-sql-instance))
    (log/warn :google-cloud-sql-connect! :pool pool)
    pool)