Fork me on GitHub
#sql
<
2023-11-24
>
J11:11:04

Hi guys! I have this code:

(let [ds (jdbc/get-datasource {:dbtype "mysql"
                               :user "..."
                               :dbname nil
                               :password "..."})
        databases (->> (jdbc/execute! ds ["SHOW DATABASES"] {:builder-fn rs/as-unqualified-lower-maps})
                       (into #{} (map :database)))]
I got the following error: No suitable driver found for jdbc: I have the driver mysql/mysql-connector-java {:mvn/version "5.1.49"} in the path. I don't understand why I got this.

dharrigan13:11:18

can you do clj -Stree and confirm the jar is in your CP?

J13:11:52

Yes I have the 5.1.49 and the 6.0.6 imported by an another lib

dharrigan13:11:31

Can you exclude one and try again?

seancorfield16:11:19

I just tried this with only next.jdbc and the 5.1.49 driver and it worked -- so I think something else in your dependencies is causing this problem:

> clj -Sdeps '{:deps {com.github.seancorfield/next.jdbc {:mvn/version "RELEASE"} mysql/mysql-connector-java {:mvn/version "5.1.49"}}}'
Downloading: com/github/seancorfield/next.jdbc/maven-metadata.xml from clojars
Downloading: mysql/mysql-connector-java/5.1.49/mysql-connector-java-5.1.49.pom from central
Downloading: mysql/mysql-connector-java/5.1.49/mysql-connector-java-5.1.49.jar from central
Clojure 1.12.0-alpha5
user=> (require '[next.jdbc :as jdbc])
nil
user=> (def ds (jdbc/get-datasource {:dbtype "mysql" :dbname "worldsingles" :user "root" :password (System/getenv "MYSQL_ROOT_PASSWORD")}))
#'user/ds
user=> (jdbc/execute! ds ["show databases"])
Fri Nov 24 08:09:33 PST 2023 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
[#:SCHEMATA{:Database "information_schema"} #:SCHEMATA{:Database "mysql"} #:SCHEMATA{:Database "performance_schema"} ...]

seancorfield16:11:13

With the 6.0.6 driver instead, I get this error

Execution error (SSLHandshakeException) at sun.security.ssl.HandshakeContext/<init> (HandshakeContext.java:162).
No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
and if I add :useSSL false to the db-spec and try again, it works as expected.

J16:11:02

Indeed there is something else in the project but I don't explain the mistake. I have deep dive to the deps and exclude the other version of the connector but still doesn't work. The workaround for the moment is to use the mysql/mysql-connector-j

seancorfield17:11:56

If the project is public, I'd be happy to take a look -- but I suspect it isn't?

J17:11:26

Oh thanks but yes it's a private repo.