FAQ

[Clojure] ANN: clojure.java.jdbc 0.0.7

Sean Corfield
Oct 11, 2011 at 9:38 pm
Changes in 0.0.7:

* Fix JDBC-9 by renaming duplicate columns instead of throwing an exception.
- thanx to Peter Siewert!
* Fix JDBC-16 by ensuring do-prepared works with no param-groups provided.
* Fix JDBC-17 by adding type hints to remove more reflection warnings.
- thanx to Stuart Sierra!
Documentation:
* Address JDBC-4 by documenting how to do connection pooling.

Plans:

Once JDBC-3 / JDBC-15 have been addressed (use of deprecated
struct-map stuff), I'll declare 0.1.0 and ask Clojure/core what would
be needed for a 1.0.0 release. Feel free to provide feedback for
future development here:

http://dev.clojure.org/display/design/java.jdbc

Earlier changes...

Changes in 0.0.6:

* Move former tests to test-utilities namespace - these do not touch a database
* Convert old "test" examples into real tests against real databases
- tested locally against MySQL, Apache Derby, HSQLDB
- build system should run against Apache Derby, HSQLSB
- will add additional databases later
* Fix JDBC-12 by removing batch when doing a single update
* Remove wrapping of exceptions in transactions to make it easier to
work with SQLExceptions

Changes in 0.0.5:

* Add prepare-statement function to ease creation of PreparedStatement
with common options:
- see docstring for details
* with-query-results now allows the SQL/params vector to be:
- a PreparedStatement object, followed by any parameters the SQL needs
- a SQL query string, followed by any parameters it needs
- options (for prepareStatement), a SQL query string, followed by
any parameters it needs
* Add support for databases that cannot return generated keys (e.g., HSQLDB)
- insert operations silently return the insert counts instead of
generated keys
- it is the user's responsibility to handle this if you're using
such a database!

Changes in 0.0.4:

* Fix JDBC-2 by allowing :table-spec {string} at the end of
create-table arguments:
(sql/create-table :foo [:col1 "int"] ["col2" :int] :table-spec
"ENGINE=MyISAM")
* Fix JDBC-8 by removing all reflection warnings
* Fix JDBC-11 by no longer committing the transaction when an Error occurs
* Clean up as-... functions to reduce use of (binding)
* Refactor do-prepared*, separating out return keys logic and
parameter setting logic
- in preparation for exposing more hooks in PreparedStatement
creation / manipulation

Changes in 0.0.3:

* Fix JDBC-10 by using .executeUpdate when generating keys (MS SQL
Server, PostgreSQL compatibility issue)

Changes in 0.0.2:

* Fix JDBC-7 Clojure 1.2 compatibility (thanx to Aaron Bedra!)

Changes in 0.0.1 (compared to clojure.contrib.sql):

* Exposed print-... functions for exception printing; no longer writes
exceptions to *out*
* Add clojure.java.jdbc/resultset-seq (to replace
clojure.core/resultset-seq which should be deprecated)
* Add support for naming and quoting strategies - see
http://clojure.github.com/java.jdbc/doc/clojure/java/jdbc/NameMapping.html
- The formatting is a bit borked, Tom F knows about this and is
working on an enhancement to auto-doc to improve it
* Add ability to return generated keys from single insert operations,
add insert-record function
* Clojure 1.3 compatibility
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
reply

Search Discussions

11 responses

  • Jaime at Oct 12, 2011 at 1:59 am
    will the 1.0.0 be included in core or contrib package?
    On Oct 12, 5:37 am, Sean Corfield wrote:
    Changes in 0.0.7:

    * Fix JDBC-9 by renaming duplicate columns instead of throwing an exception.
    - thanx to Peter Siewert!
    * Fix JDBC-16 by ensuring do-prepared works with no param-groups provided.
    * Fix JDBC-17 by adding type hints to remove more reflection warnings.
    - thanx to Stuart Sierra!
    Documentation:
    * Address JDBC-4 by documenting how to do connection pooling.

    Plans:

    Once JDBC-3 / JDBC-15 have been addressed (use of deprecated
    struct-map stuff), I'll declare 0.1.0 and ask Clojure/core what would
    be needed for a 1.0.0 release. Feel free to provide feedback for
    future development here:

    http://dev.clojure.org/display/design/java.jdbc

    Earlier changes...

    Changes in 0.0.6:

    * Move former tests to test-utilities namespace - these do not touch a database
    * Convert old "test" examples into real tests against real databases
    - tested locally against MySQL, Apache Derby, HSQLDB
    - build system should run against Apache Derby, HSQLSB
    - will add additional databases later
    * Fix JDBC-12 by removing batch when doing a single update
    * Remove wrapping of exceptions in transactions to make it easier to
    work with SQLExceptions

    Changes in 0.0.5:

    * Add prepare-statement function to ease creation of PreparedStatement
    with common options:
    - see docstring for details
    * with-query-results now allows the SQL/params vector to be:
    - a PreparedStatement object, followed by any parameters the SQL needs
    - a SQL query string, followed by any parameters it needs
    - options (for prepareStatement), a SQL query string, followed by
    any parameters it needs
    * Add support for databases that cannot return generated keys (e.g., HSQLDB)
    - insert operations silently return the insert counts instead of
    generated keys
    - it is the user's responsibility to handle this if you're using
    such a database!

    Changes in 0.0.4:

    * Fix JDBC-2 by allowing :table-spec {string} at the end of
    create-table arguments:
    (sql/create-table :foo [:col1 "int"] ["col2" :int] :table-spec
    "ENGINE=MyISAM")
    * Fix JDBC-8 by removing all reflection warnings
    * Fix JDBC-11 by no longer committing the transaction when an Error occurs
    * Clean up as-... functions to reduce use of (binding)
    * Refactor do-prepared*, separating out return keys logic and
    parameter setting logic
    - in preparation for exposing more hooks in PreparedStatement
    creation / manipulation

    Changes in 0.0.3:

    * Fix JDBC-10 by using .executeUpdate when generating keys (MS SQL
    Server, PostgreSQL compatibility issue)

    Changes in 0.0.2:

    * Fix JDBC-7 Clojure 1.2 compatibility (thanx to Aaron Bedra!)

    Changes in 0.0.1 (compared to clojure.contrib.sql):

    * Exposed print-... functions for exception printing; no longer writes
    exceptions to *out*
    * Add clojure.java.jdbc/resultset-seq (to replace
    clojure.core/resultset-seq which should be deprecated)
    * Add support for naming and quoting strategies - seehttp://clojure.github.com/java.jdbc/doc/clojure/java/jdbc/NameMapping...
    - The formatting is a bit borked, Tom F knows about this and is
    working on an enhancement to auto-doc to improve it
    * Add ability to return generated keys from single insert operations,
    add insert-record function
    * Clojure 1.3 compatibility
    --
    Sean A Corfield -- (904) 302-SEAN
    An Architect's View --http://corfield.org/
    World Singles, LLC. --http://worldsingles.com/
    Railo Technologies, Inc. --http://www.getrailo.com/

    "Perfection is the enemy of the good."
    -- Gustave Flaubert, French realist novelist (1821-1880)
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Sean Corfield at Oct 12, 2011 at 2:10 am

    On Tue, Oct 11, 2011 at 6:58 PM, jaime wrote:
    will the 1.0.0 be included in core or contrib package?
    The Clojure/core team have indicated they are considering a "batteries
    included" distribution that will bundle new contrib libraries but the
    exact form (and version numbers) have not been discussed in any
    detail.
    --
    Sean A Corfield -- (904) 302-SEAN
    An Architect's View -- http://corfield.org/
    World Singles, LLC. -- http://worldsingles.com/
    Railo Technologies, Inc. -- http://www.getrailo.com/

    "Perfection is the enemy of the good."
    -- Gustave Flaubert, French realist novelist (1821-1880)

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Keeds at Oct 12, 2011 at 8:42 am
    I have been converting a project to Clojure 1.3 which meant moving to
    clojure.java.jdbc.
    I'm having problems with MS Access ODBC driver with JDBC ODBC bridge and
    parameterised statements.
    I've just tried 0.0.7 and still have the same problem:

    Exception in thread "main" java.lang.RuntimeException:
    java.sql.SQLException: SQL Exception : [Micro
    soft][ODBC Microsoft Access Driver]Optional feature not implemented
    at clojure.lang.Util.runtimeException(Util.java:165)
    at clojure.lang.LazySeq.sval(LazySeq.java:51)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:466)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$dorun.invoke(core.clj:2723)
    at
    clojure.java.jdbc.internal$set_parameters.invoke(internal.clj:241)
    at
    clojure.java.jdbc.internal$with_query_results_STAR_.invoke(internal.clj:352)
    at mad.reports$get_target$fn__2949.invoke(reports.clj:390)
    at
    clojure.java.jdbc.internal$with_connection_STAR_.invoke(internal.clj:156)
    at mad.reports$get_target.invoke(reports.clj:389)
    at mad.reports$newChart.doInvoke(reports.clj:446)
    at clojure.lang.RestFn.invoke(RestFn.java:497)
    at mad.reports$optChart.invoke(reports.clj:488)
    at mad.reports$genCharts.invoke(reports.clj:501)
    at mad.reports$newReport.invoke(reports.clj:507)
    at mad.reports$all_reports.invoke(reports.clj:518)
    at mad.core$_main.doInvoke(core.clj:7)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.Var.invoke(Var.java:397)
    at user$eval159.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6465)
    at clojure.lang.Compiler.eval(Compiler.java:6455)
    at clojure.lang.Compiler.eval(Compiler.java:6431)
    at clojure.core$eval.invoke(core.clj:2795)
    at clojure.main$eval_opt.invoke(main.clj:296)
    at clojure.main$initialize.invoke(main.clj:315)
    at clojure.main$null_opt.invoke(main.clj:348)
    at clojure.main$main.doInvoke(main.clj:426)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:405)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:518)
    at clojure.main.main(main.java:37)
    Caused by: java.sql.SQLException: SQL Exception : [Microsoft][ODBC Microsoft
    Access Driver]Optional
    feature not implemented
    at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setObject(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setObject(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setObject(Unknown Source)
    at
    clojure.java.jdbc.internal$set_parameters$fn__63.invoke(internal.clj:243)
    at
    clojure.core$map_indexed$mapi__5759$fn__5760.invoke(core.clj:6328)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    ... 32 more

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Sean Corfield at Oct 13, 2011 at 6:26 am

    On Wed, Oct 12, 2011 at 1:42 AM, keeds wrote:
    I'm having problems with MS Access ODBC driver with JDBC ODBC bridge and
    parameterised statements.
    Given how flawed MS Access is, I'm not sure it's an appropriate target
    for clojure.java.jdbc but if you can provide more detail about exactly
    what query you tried (that failed) and whether it ever worked with
    clojure.contrib.sql, I can try to take a look at it.
    --
    Sean A Corfield -- (904) 302-SEAN
    An Architect's View -- http://corfield.org/
    World Singles, LLC. -- http://worldsingles.com/
    Railo Technologies, Inc. -- http://www.getrailo.com/

    "Perfection is the enemy of the good."
    -- Gustave Flaubert, French realist novelist (1821-1880)

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Keeds at Oct 13, 2011 at 9:13 am
    Hi,
    Don't disagree about MS Access but it's a useful simple tool some times...

    The code is:
    (defn get-target
    [bu measure year]
    (with-connection db
    (with-query-results rs ["Select Period_Month, Target From Targets_Qry
    Where BU_ID = ? And Measure_Code = ? And Period_Year = ?" bu measure year]
    (to-dataset (into [] rs)))))

    It worked fine with clojure 1.2 and clojure.contrib.sql

    Thanks,
    Andrew

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Marko Kocić at Oct 13, 2011 at 8:35 am
    Looking at the log seems like MS Access doesn't support prepared statements.
    It shouldn't have anything to do with jdbc.

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Sean Corfield at Oct 15, 2011 at 7:37 am

    On Thu, Oct 13, 2011 at 1:35 AM, Marko Kocić wrote:
    Looking at the log seems like MS Access doesn't support prepared statements.
    Ah, so there was a path in c.c.sql that didn't use PreparedStatement
    which meant it supported MS Access? (by accident, I'm sure :)

    If someone with a Windows system can figure out a patch for c.j.jdbc
    that would re-enable that behavior without breaking any other
    behaviors, I'd be happy to entertain it in a JIRA ticket.
    Unfortunately, I don't have access to MS Access to do any such
    testing...
    --
    Sean A Corfield -- (904) 302-SEAN
    An Architect's View -- http://corfield.org/
    World Singles, LLC. -- http://worldsingles.com/
    Railo Technologies, Inc. -- http://www.getrailo.com/

    "Perfection is the enemy of the good."
    -- Gustave Flaubert, French realist novelist (1821-1880)

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Keeds at Nov 7, 2011 at 1:56 pm
    Sean,
    I've broken down the code and added some println's to contrib.sql and it
    does use preparedstatements and .setObject to set parameters for the MS
    Access queries.
    Changing the same SQL code to use clojure 1.3.0 and latest java.jdbc I get
    the error message.

    The implementation in contrib.sql and java.jdbc of with-query-results* is
    basically the same but I've no experience of macro's to better understand
    it.

    I'm not sure how to investigate further...

    Thanks,
    Andrew

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Keeds at Nov 7, 2011 at 11:04 pm
    Sorry to answer my own question...

    Some more (blind) delving shows that the only difference between the
    versions is that clojure1.2 and contrib pass the 14 value as a
    java.lang.Integer whereas clojure1.3 and java.jdbc pass the value 14 as a
    java.lang.Long and this is what blows the .setObject call.

    Strings work fine as does forcing 14 to be an Integer by passing it as
    (Integer. 14)

    I assume a change in clojure1.3 for the type changes.
    Not sure why a Long should be an invalid type though?

    Anybody able to shed anymore light?

    Thanks,
    Andrew

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Sean Corfield at Nov 8, 2011 at 6:18 am

    On Mon, Nov 7, 2011 at 3:04 PM, keeds wrote:
    Some more (blind) delving shows that the only difference between the
    versions is that clojure1.2 and contrib pass the 14 value as a
    java.lang.Integer whereas clojure1.3 and java.jdbc pass the value 14 as a
    java.lang.Long and this is what blows the .setObject call.
    Strings work fine as does forcing 14 to be an Integer by passing it as
    (Integer. 14)
    Glad to hear you have a workaround. Yes, in 1.3 all primitive
    arithmetic is done in long and double so when values are boxed, they
    become Long and Double. However, as you've seen, you can explicitly
    box them as Integer (and Float).
    Not sure why a Long should be an invalid type though?
    No idea. Some aspect of the JDBC-ODBC bridge, perhaps?
    --
    Sean A Corfield -- (904) 302-SEAN
    An Architect's View -- http://corfield.org/
    World Singles, LLC. -- http://worldsingles.com/

    "Perfection is the enemy of the good."
    -- Gustave Flaubert, French realist novelist (1821-1880)

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Stuart Sierra at Oct 12, 2011 at 12:49 pm
    Thanks for the quick release of JDBC-17!
    -S

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en

Related Discussions

Discussion Navigation
viewthread | post