oracle connection help

229 views
Skip to first unread message

Timothy Pratley

unread,
May 6, 2013, 3:22:55 AM5/6/13
to sqlk...@googlegroups.com
Hi,


Korma looks very nice but I'm having a tough time connecting to an Oracle DB...
my endpoint is u/p@tpratleyw7/tw
I can communicate using direct mode through linqpad direct mode and oci (along with other tools)
But can't figure out the special incantation in Korma.
Also is there a way to just test that the connection can be established without doing any entity/select?
Here are two forms I have tried which I believe should work based upon the connection string... but don't
[I've tried various others which also failed]
Any tips how I can make it work or debug further?

(defdb tc (oracle {:host "tpratleyw7"
                   :port "tw"
                   :user "tc_col_own"
                   :password "tc_col_own"
                   :naming {:keys string/lower-case
                            :fields string/upper-case}}))

(defdb tc {:classname   "oracle.jdbc.OracleDriver"
           :subprotocol "oracle:thin"
           :subname "@//tpratleyw7/tw"
           :user     "u"
           :password "p"
           :make-pool? true})

(defentity containers
  (pk :ContainerId)
  (table :Container))

(select containers
        (aggregate (avg :weight) :average))


java.sql.SQLException: Connections could not be acquired from the underlying database!
                SqlUtils.java:106 com.mchange.v2.sql.SqlUtils.toSQLException
C3P0PooledConnectionPool.java:529 com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection
AbstractPoolBackedDataSource.java:128 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection
                     jdbc.clj:192 clojure.java.jdbc/get-connection
                     jdbc.clj:307 clojure.java.jdbc/with-connection*
                       db.clj:226 korma.db/do-query
                     core.clj:474 korma.core/exec
                NO_SOURCE_FILE:40 linq.core/eval5664

Timothy Pratley

unread,
May 6, 2013, 4:52:14 AM5/6/13
to sqlk...@googlegroups.com
I figured it out...

(ns linq.core
  (:use [korma.db]
        [korma.core])
  (:require [clojure.string :as string]))

(defdb tc {:classname "oracle.jdbc.driver.OracleDriver"
           :subprotocol "oracle"
           :subname "thin:@tpratleyw7:1521:TW"
           :user "u"
           :password "p"
           :naming {:keys string/upper-case
                    :fields string/upper-case}})

(defentity containers
  (table :container))

(select containers
        (aggregate (avg :weight) :average))


Add to your project file:
                 [org.clojars.gukjoon/ojdbc "1.4"]

And... it works... yay :)



Sorry for the noise

Reply all
Reply to author
Forward
0 new messages