Guest User

Untitled

a guest
Apr 7th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. (defn do-with-connection [f]
  2. (let [con (.getConnection DriverManager "jdbc:mysql://localhost/paulbarry?user=root")]
  3. (let [r (f con)]
  4. (.close con)
  5. r)))
  6.  
  7. (defn select-first [sql]
  8. (do-with-connection
  9. (fn [con]
  10. (let [rs (.executeQuery (.createStatement con) sql)]
  11. (.next rs)
  12. (.getString rs 1)))))
Add Comment
Please, Sign In to add comment