I'm trying to build a project in clojure that takes data from a Microsoft SQL Server database, and pushes it to a MySQL database.
The project runs fine using lein run, but when I package it into an uberjar using leiningen, and run it using java -jar, it fails with:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:sqlserver....
This error only happens when I attempt to use both the MySQL database and the SQL Server database. If I use any one of them on its own, the jar file runs fine using java -jar.
My project.clj is as follows:
(defproject sqlserver-clojure "1.0.0-SNAPSHOT"
:description "A minimal example of the MySQL/SQLServer conflict"
:dependencies [[org.clojure/clojure "1.4.0"]
[com.microsoft/sqljdbc4 "3.0"]
[clojureql "1.0.4"]
[mysql/mysql-connector-java "5.1.6"]]
:main sqlserverclojure.core)
META-INF
, or worse overwriting them (egMETA-INF/services/java.sql.Driver
exists in all JDBC 4 compliant drivers with different content) – Mark RotteveelClass.forName("driver.class.Name")
somewhere in your application before using JDBC. Alternately you could useDataSource
objects instead ofDriverManager.getConnection()
– millimooseMETA-INF/services/java.sql.Driver
was just an example, the loading of the driver could still fail (even when using the classic method or aDataSource
), for example because other required resources weren't copied – Mark RotteveelMETA-INF/
that could have filename conflicts besides the relatively few features of the JDK that make use of that information. And beyond that "something else might fail" comes across as FUD-spreading. – millimoose