clojure/java.jdbc

Name: java.jdbc

Owner: Clojure

Description: JDBC from Clojure (formerly clojure.contrib.sql)

Created: 2011-04-17 11:36:42.0

Updated: 2018-01-17 10:43:38.0

Pushed: 2018-01-12 20:43:02.0

Homepage:

Size: 1842

Language: Clojure

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

clojure.java.jdbc

A low-level Clojure wrapper for JDBC-based access to databases.

For higher level DSLs and migration libraries that are compatible, see the documentation.

Formerly known as clojure.contrib.sql.

Documentation

Support

Releases and Dependency Information

Latest stable release: 0.7.5 – requires Clojure 1.7 or later!

Leiningen dependency information:

.clojure/java.jdbc "0.7.5"]

Maven dependency information:

endency>
roupId>org.clojure</groupId>
rtifactId>java.jdbc</artifactId>
ersion>0.7.5</version>
pendency>

Note: Earlier versions of Clojure are supported by older versions of clojure.java.jdbc: e.g., version 0.6.1 supports Clojure 1.4 and later.

You will also need to add dependencies for the JDBC driver you intend to use. Here are links (to Maven Central) for each of the common database drivers that clojure.java.jdbc is known to be used with:

Note: different versions of various database drivers have different Java/JVM version requirements. In particular, recent versions of Apache Derby require at least Java 8 and recent versions of H2 require at least Java 7. Clojure's Continuous Integration system uses older versions so tests can be run on Java 6 (see pom.xml); local testing is done with more recent versions on Java 8.

Example Usage

uire '[clojure.java.jdbc :as j])

here are many ways to write a db-spec but the easiest way is to
se :dbtype and then provide the :dbname and any of :user, :password,
host, :port, and other options as needed:
 mysql-db {:dbtype "mysql"
           :dbname "clojure_test"
           :user "clojure_test"
           :password "clojure_test"})

 pg-db {:dbtype "postgresql"
        :dbname "mypgdatabase"
        :host "mydb.server.com"
        :user "myuser"
        :password "secret"
        :ssl true
        :sslfactory "org.postgresql.ssl.NonValidatingFactory"})

f the dbtype is not known to clojure.java.jdbc, or you want to override the
efault choice of JDBC driver class name, you can provide :classname and the
ame of the class to use:

 redshift42 {:dbtype "redshift"
             :dbname "myredstore"
             :classname "com.amazon.redshift.jdbc42.Driver"
             ...})

ou can also specify a full connection string if you'd prefer:
 pg-uri
connection-uri (str "postgresql://myuser:secret@mydb.server.com:5432/mypgdatabase"
                    "?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory")})

nsert-multi! mysql-db :fruit
:name "Apple" :appearance "rosy" :cost 24}
:name "Orange" :appearance "round" :cost 49}])
{:generated_key 1} {:generated_key 2})

uery mysql-db
select * from fruit where appearance = ?" "rosy"]
row-fn :cost})
24)

For more detail see the API reference or documentation.

Developer Information

Change Log

Copyright and License

Copyright (c) Sean Corfield, Stephen Gilardi, 2011-2014. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.