How to add JDBC-supported database (Informix) into korma

雨燕双飞 提交于 2019-12-11 21:17:49

问题


What steps do I need to take to allow my Informix JDBC driver to be a supported database in korma? Informix has a jdbc driver, and I have tested with the driver's demo Java programs. My connection parameters work.

I've gone ahead and started a Clojure project, but I'm stuck on what to try even to get an error, so I can move forward from there, let alone connecting.

My Informix JDBC driver 3.50 is in maven

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

The following example is for postgres. I want to do this for Informix. I am wondering what I have to do so that I can create a connection for the Informix database using something similar to

(defdb prod (postgres {:db "korma"
                       :user "korma"
                       :password "kormapass"
                       ;; optional keys
                       :host "myhost"
                       :port "4567"
                       :delimiters ""}))

I am pretty sure I cannot just use "informix" in place of postgres in the example above, and magic will happen. I am just puzzled as to what defintions to create. Any help or pointers to examples would be appreciated.


回答1:


Try using classname and subprotocol attributes:

(def db-config {:classname "com.informix.jdbc.IfxDriver"
                :subprotocol "informix-sqli"
                :subname (format "//%s:1533/%s" 
                                 "123.45.67.89"
                                 "testDB:INFORMIXSERVER=myserver")
                :user "user"
                :password "password"})

(defdb db db-config)

Take a look at the different definitions in the source code, postgres is just a shorthand for those attributes. Even if there's no informix predefined function you can roll your own.

According to this doc driver name is com.informix.jdbc.IfxDriver, you can also check there for database URIs:

The following example shows a database URL that connects 
to a database called testDB:

jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
user=rdtest;password-test

Also remember 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"]]


来源:https://stackoverflow.com/questions/22206067/how-to-add-jdbc-supported-database-informix-into-korma

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!