sql

J 2023-11-24T11:45:04.862959Z

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.

dharrigan 2023-11-24T13:31:18.055969Z

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

J 2023-11-24T13:36:52.192529Z

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

dharrigan 2023-11-24T13:39:31.656569Z

Can you exclude one and try again?

seancorfield 2023-11-24T16:11:19.855219Z

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"} ...]

seancorfield 2023-11-24T16:13:13.047479Z

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.

J 2023-11-24T16:21:02.191939Z

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

seancorfield 2023-11-24T17:23:56.487979Z

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

J 2023-11-24T17:28:26.093509Z

Oh thanks but yes it's a private repo.