Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#5 Have select use prep statements

open
David Hoag
5
2003-11-24
2003-11-24
David Hoag
No

Change the code to support the use of prepared
statements for the "selects".

This could potentially improve performance.

Discussion

  • David Hoag
    David Hoag
    2003-11-24

    Logged In: YES
    user_id=4387

    Modify the SqlStatementCacheItem to take a SQLAssembler
    instead of only a SQLModifier. This allows you to reuse the
    logic and code doing updates/inserts for select support. This
    will drive new methods that need to be added to the
    SQLAssembler interface.

    Modify the SQLAssembler interface to support the necessary
    prep statement methods. I suspect you'll only need to add
    one or two methods: something like "bindValues"
    and "getPreparedString" ... not sure, just a guess.

    Refactor SQLModifier to move all of the Prep Statement
    specific logic into another class. Update SQLModifier to
    always instantiate that class at construction and delegate
    existing methods to that class. This allows you to reuse that
    code for the SQLSelect.

    Implement the new SQLAssembler methods by using an
    instance of the newly refactored class as the implementation
    logic.

    ... Next start looking at the RDBConnection - first modify the
    createStatement & addStatement method to accept the
    SQLAssembler.

    Create a new method that is 90% similar to
    prepareUpdateSql. PrepareUpdateSql presumes that it's doing
    an update and not a select, so you won't be able to just
    change it - you'll need a whole new method:
    prepareSelectSql.