Fork me on GitHub
#sql
<
2023-04-13
>
rpatrelle13:04:36

Hi everybody, I try to use a HikariCP threadpool with next.jdbc. this works well with local mysql container but fails when I try to reach AWS instance. We use mysql version 5.7. I tried this repl code without success:

(let [config {:dbtype "mysql",
              :password "***********",
              :dataSourceProperties {:socketTimeout 30},
              :username "*******",
              :port 3306,
              :dbname "dco",
              :host
              "*******."
              :useSSL false}
      reader (connection/->pool HikariDataSource config)]
  (jdbc/execute!
   reader
   (sql/format {:select :column_name
                :from :INFORMATION_SCHEMA.COLUMNS})))
Error returned is :
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
                                                         
                                                         The last packet successfully received from the server was 2 milliseconds ago.  The last packet sent successfully to the server was 1 milliseconds ago.
     SQLState: "08S01"
    errorCode: 0

Execution error (SSLHandshakeException) at sun.security.ssl.HandshakeContext/<init> (HandshakeContext.java:170).
No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
I try to use play with enabledTLSProtocols or tlsVersions still without success

seancorfield15:04:30

Hard to say, but that error sounds like AWS requires SSL and you have it turned off.

rpatrelle15:04:18

It works we specify the jdbc-url in the db-spec . It works also without threadpool.

seancorfield15:04:33

What is the value of :jdbc-url that works? Perhaps you haven't correctly mapped it to the db-spec hash map?

rpatrelle15:04:46

jdbc:mysql://`host`:`port`/`dbname`?useSSL=false

seancorfield15:04:04

Oh, right, HikariCP doesn't have a useSSL option -- that's why the hash map approach doesn't work.

seancorfield15:04:16

So, yeah, you'll have to use the JDBC URL approach with HikariCP.

seancorfield15:04:35

You could use next.jdbc.connection/jdbc-url to construct (most of) the URL (without username/password) I think -- that will save you string-bashing.

rpatrelle15:04:36

Ah yes, nice, we built it manually 😅

seancorfield15:04:02

BTW, did you try putting :useSSL false into the :dataSourceProperties hash map? I'm not sure whether that would work but it's worth trying...

rpatrelle15:04:29

Yes, we tried. It doesn't work

seancorfield15:04:38

OK, thanks. I'll try to improve the docs in this area: https://github.com/seancorfield/next-jdbc/issues/247

🙏 2