clojure/java.jdbc — pull request #34 by pazustep (2013-12-26 19:10:26+00:00)
Title: Introduces the IPreparedStatementSetParameter protocol

This protocol allows users to override how prepared statement
parameters are set. The default implementation keeps the current
behavior of using sql-value to convert the value and then calling
the PreparedStatement#setObject(int, Object) method.

As an example, and the motivation for this change,
here's a protocol implementation for joda.time.ReadableInstant values
that uses the three argument #setTimestamp() method to keep timezone
information:

(extend-protocol IPreparedStatementSetParameter
org.joda.time.ReadableInstant
(prepared-statement-set-parameter [instant stmt idx]
(let [timestamp (java.sql.Timestamp. (.getMillis instant))
timezone (.. instant getZone toTimeZone)
calendar (java.util.Calendar/getInstance timezone)])
(.setTimestamp stmt idx timestamp calendar)))