<< Back to previous view

[JDBC-6] Add hook to allow operations on PreparedStatement prior to query execution Created: 26/May/11  Updated: 10/Aug/11  Resolved: 10/Aug/11

Status: Resolved
Project: java.jdbc
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Sean Corfield Assignee: Sean Corfield
Resolution: Completed Votes: 0
Labels: None


 Description   

It would be very useful to be able to pass in a function argument to several c.j.j functions that would be called on the PreparedStatement before executing the query, for example, calling setFetchSize(). I'm not sure what the syntax should look like for this...



 Comments   
Comment by Sean Corfield [ 17/Jul/11 3:36 AM ]

I've started the work to reorganize the code to better expose the statement object for this sort of manipulation.

Comment by Sean Corfield [ 17/Jul/11 5:57 PM ]

Two options under consideration:

  • allow raw PreparedStatement to be passed in by user where appropriate so they have complete control
  • allow map of settings that would be used to create the PreparedStatement and set its options

I like the latter better but Alan Malloy made the point that the former may still be needed for total control anyway.

I'm leaning toward adding a function to ease creation of PreparedStatement objects to at least provide a clean API and then I'll consider how best to integrate that with the other functions.

Comment by Sean Corfield [ 17/Jul/11 10:02 PM ]

Added prepare-statement* to jdbc.internal which takes a connection, a SQL string and a map of options; returns a PreparedStatement. Will expose this in top-level.

with-query-results now allows the first element in the sql-params vector to be either:

  • PreparedStatement object created by the user
  • map of options passed to prepare-statement* in order to create the PreparedStatement

Options supported are in the docstring. May add additional post-creation options (beyond fetch-size and max-rows).

Comment by Sean Corfield [ 10/Aug/11 2:23 AM ]

Users have verified that being able to specify :fetch-size in with-query-results handles the common use cases for performance.

Generated at Thu Apr 17 11:19:41 CDT 2014 using JIRA 4.4#649-r158309.