Commits

Shantanu Kumar committed b994aec

add MonetDB support

Comments (0)

Files changed (4)

 - Improved support for MS-Excel workbooks via JDBC-ODBC bridge driver
 - [TODO] properties support in DataSource JDBC URL
 - [TODO] protocols for memory-connect, file-connect, net-connect
-- [TODO] MonetDB support
+- MonetDB support
 - [TODO] MckoiDDB support
 - Support for Java 7 (JDBC 4.1)
 - Use OSS-JDBC 0.6

src/main/clj/org/bituf/clj_dbcp.clj

 
 
 (def ^{:doc "Clj-DBCP version - major and minor only"}
-      version [0 5])
+      version [0 6])
 
 
 (def ^{:doc "Boolean flag (default false) - prints the JDBC URL if true"
       "SELECT 1;")))
 
 
+; === MonetDB config ===
+;
+(defn monetdb-args
+  "Create datasource args for the MonetDB database. The default database port is
+  50000. Example JDBC URL:
+    jdbc:monetdb://localhost:50000/demo
+  Arguments:
+    db-host:port  (String) database hostname and :port-no (colon, then port-no)
+    db-name       (String) database name to connect to
+    username      (String) database username
+    password      (String) password for the database user
+  Examples:
+    (monetdb-args \"localhost\" \"sales\" \"salesuser\" \"secret\")
+    (monetdb-args \"localhost:50000\" \"emp\"   \"empuser\"   \"SeCrEt\")
+  See also: http://monetdb-xquery.org/SQL/Documentation/The-JDBC-Library.html
+            http://j.mp/trXYGP (short URL of the above)"
+  [db-host:port db-name username password]
+  (let [url (format "jdbc:monetdb://%s/%s" db-host:port db-name)]
+    (if *show-jdbc-url*
+      (println "\n**** MonetDB JDBC URL ****\n" url))
+    (make-datasource-args
+      "nl.cwi.monetdb.jdbc.MonetDriver" ; classname: must be in classpath
+      url
+      username ; username
+      password ; password
+      )))
+
+
+(defn monetdb-datasource
+  "Create MonetDB data source
+  See also: monetdb-args"
+  [db-host:port db-name username password]
+  (let [args (monetdb-args
+               db-host:port db-name username password)
+        ds   (make-datasource args)]
+    (set-validation-query! ds
+      "SELECT 1;")))
+
+
 ; === Firebird config ===
 ;
 (defn firebird-args
    ;; regular, open source, network-only databases
    :cubrid             (partial on-network cubrid-datasource)
    :firebird           (partial on-network firebird-datasource)
+   :monetdb            (partial on-network monetdb-datasource)
    :mysql              (partial on-network mysql-datasource)
    :pgsql              (partial on-network pgsql-datasource)
    ;; regular, proprietary, network-only databases

src/test/clj/org/bituf/test_clj_dbcp.clj

     (fail "CUBRID not tested")))
 
 
+(deftest test-monetdb
+  (if (tu/is-true? (:monetdb.testconn dbcred))
+    (test-network-datasource "monetdb" monetdb-datasource)
+    (fail "monet not tested")))
+
+
 (deftest test-pgsql
   (if (tu/is-true? (:pgsql.testconn dbcred))
     (test-network-datasource "pgsql" pgsql-datasource)
   (test-firebird)
   (test-mysql)
   (test-cubrid)
+  (test-monetdb)
   (test-pgsql)
   (smoketest-untested-datasources)
   (test-jndi)

src/test/dbcred.properties

 cubrid.username=dba
 cubrid.password=root
 
+# MonetDB credentials
+# hostport can also be in the form "localhost:50000"
+monetdb.testconn=true
+monetdb.hostport=localhost
+monetdb.database=demo
+monetdb.username=bituf
+monetdb.password=bituf
+
 # PostgreSQL credentials
 # hostport can also be in the form "localhost:5432"
 pgsql.testconn=true