aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/sql
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2009-01-04 18:47:18 +0000
committerscgilardi <scgilardi@gmail.com>2009-01-04 18:47:18 +0000
commit10762826a3862bd32d33a3e248a9fbd4569b5f5a (patch)
tree75f029796ed74510c7beb4a26ce3f4ed6cbacc6d /src/clojure/contrib/sql
parenta2fc8fb7c7dd0f376246b8db452a58436cbc57c8 (diff)
sql: make 'connection' public, a function that returns the current database connection or throws if there is none
Diffstat (limited to 'src/clojure/contrib/sql')
-rw-r--r--src/clojure/contrib/sql/internal.clj14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/clojure/contrib/sql/internal.clj b/src/clojure/contrib/sql/internal.clj
index 8d6e8414..8d17552c 100644
--- a/src/clojure/contrib/sql/internal.clj
+++ b/src/clojure/contrib/sql/internal.clj
@@ -15,22 +15,12 @@
(def *db* {:connection nil :level 0})
-(defn connection
+(defn connection*
"Returns the current database connection or throws"
[]
(or (:connection *db*)
(throw (Exception. "no current database connection"))))
-(defn create-statement
- "Creates a statement object on the current connection"
- []
- (.createStatement (connection)))
-
-(defn prepare-statement
- "Creates a prepared statement object on the current connection"
- [sql]
- (.prepareStatement (connection) sql))
-
(defn the-str
"Returns the name or string representation of x"
[x]
@@ -73,7 +63,7 @@
or rolled back on any uncaught exception. Any nested transactions are
absorbed into the outermost transaction."
[thunk]
- (let [con (connection)
+ (let [con (connection*)
outermost (zero? (:level *db*))
auto-commit (when outermost (.getAutoCommit con))]
(binding [*db* (update-in *db* [:level] inc)]