Question

This question is a follow-on to this question, but I felt was different enough to warrant a separate post.

How do I configure Clojure, to recognize an Informix jdbc driver? I am using leiningen.

I have read this post, but am still confused. My Informix JDBC driver is in maven. I installed it this way:

mvn install:install-file \
-DgroupId=com.informix \
-DartifactId=ufxjdbc \
-Dversion=3.50.JC9 \
-Dfile=/opt/IBM/Informix_JDBC_Driver/lib/ifxjdbc.jar \
-Dpackaging=jar \
-DgeneratePom=true

I have spoken to IBM (Informix) support, and the fact I can run their java demo programs means their JDBC driver is working correctly.

Because of this error:

Exception in thread "main" java.sql.SQLException: 
No suitable driver found for 
jdbc:informix-sqli://steamboy:1498/stores7/ministores:INFORMIXSERVER=steamboy

Informix support thinks I need to configure Clojure/leiningen, so it can find the Informix JDBC driver.

This driver is not in the usual leiningen dependent directories, and Informix support said something about getting the driver into Clojure's classpath. I thought that meant installing in Maven.

project.clj

(defproject db-test "0.1.0-SNAPSHOT"
  :description "Clojure database test"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/tools.cli "0.1.0"]
                 [org.clojure/java.jdbc "0.3.3"]]
   :main db-test.core)

core.clj (reduced for brevity)

(ns db-test.core

  (require [clojure.string :as str])
  (require [clojure.java.jdbc :as j])
  (:use [clojure.tools.cli])
  (:import java.util.Date)
  (:gen-class)
)


(defn -main 
  [& args]
  (def informix-db {:classname "com.informix.jdbc.IfxDriver"
                    :subprotocol "informix-sqli"
                    :subname (format "//%s:%s/%s:INFORMIXSERVER=%s" 
                    (:host opts)
                    (:port opts)
                    (:database opts)
                    (:server opts))
                    :user (:user opts)
                    :password (:password opts)})

        (let [customer-list 
        (j/query informix-db
          ["select * from customer"])]
          (doseq [customer customer-list]
            (println customer))))))

I would appreciate any pointers or help.

Was it helpful?

Solution

You need to add the proper dependency information to your project.clj file:

 :dependencies [[com.informix.jdbc/com.springsource.com.informix.jdbc "3.0.0.JC3"]...

And the springsource repositories for that dependency to be found:

  :repositories [["springsource-release" "http://repository.springsource.com/maven/bundles/release"]
                 ["springsource-external" "http://repository.springsource.com/maven/bundles/external"]]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top