java.jdbc

Add hook to allow operations on PreparedStatement prior to query execution

Details

  • Type: Enhancement Enhancement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • 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...

Activity

Hide
Sean Corfield added a comment -

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

Show
Sean Corfield added a comment - I've started the work to reorganize the code to better expose the statement object for this sort of manipulation.
Sean Corfield made changes -
Field Original Value New Value
Status Open [ 1 ] In Progress [ 3 ]
Hide
Sean Corfield added a comment -

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.

Show
Sean Corfield added a comment - 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.
Hide
Sean Corfield added a comment -

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).

Show
Sean Corfield added a comment - 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).
Hide
Sean Corfield added a comment -

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

Show
Sean Corfield added a comment - Users have verified that being able to specify :fetch-size in with-query-results handles the common use cases for performance.
Sean Corfield made changes -
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Completed [ 1 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: