Fork me on GitHub
#sql
<
2018-11-13
>
michaellindon23:11:19

@seancorfield you recently helped me set up drivers for a postgres database. Now I want to connect to a microsoft sql database 🙂

michaellindon23:11:49

currently i get

SQLException No suitable driver found for jdbc:  java.sql.DriverManager.getConnection (DriverManager.java:702)

seancorfield23:11:44

Did you add a dependency for a SQL Server JDBC driver?

michaellindon23:11:50

from my other client the url i use looks like jdbc:jtds:

michaellindon23:11:00

ill try adding the dependency [net.sourceforge.jtds/jtds "1.3.1"] but not sure exactly what im doing XD

seancorfield23:11:36

You can either use the Microsoft driver or the jTDS driver -- but they require different :dbtype values.

seancorfield23:11:22

If you use the jTDS driver, your :dbtype should be "jtds", if you use the MS driver, your :dbtype should be "mssql"

michaellindon23:11:56

that makes sense, thank you. I never got the MS drivers to work well from a mac so I think ill work with jtds. Was the dependency I added the correct one for jtds?

seancorfield23:11:22

You can see what clojure.java.jdbc is tested against here https://github.com/clojure/java.jdbc/blob/master/deps.edn

seancorfield23:11:44

(in particular, the group/artifact and version of each of the drivers)

seancorfield23:11:41

With the jTDS driver, your db-spec can be {:dbtype "jtds" :dbname "xxxx" :user "..." :password "..."} -- with :host "..." if it's on another machine

seancorfield23:11:13

(that way you don't have to worry about how to create the actual URL)