Results 1 to 3 of 3

Thread: jdbcTemplate query for object too slow

  1. #1
    Join Date
    Mar 2008
    Posts
    5

    Default jdbcTemplate query for object too slow

    I'm using the following code in a Spring Batch app. This is taking about 600mS to complete. It is running against a DB2 table on a mainframe. This will execute about 400,000 times and will cause to app to run too long. How can I speed this up.


    Code:
    matchingKeyTable = (KeyTable) getJdbcTemplate().queryForObject(fetch_Keytable_Sql, 
    new Object[]{alIdL, blIdL } , new KeyTableMapper()
    					);

  2. #2
    Join Date
    Feb 2008
    Posts
    488

    Default

    Without having any context whatsoever, it's hard to give a precise answer. But, generally speaking, you'd probably want to do fewer queries. For example, can you query for a list and iterate through them?
    Last edited by DHGarrette; Jul 16th, 2009 at 06:57 PM. Reason: spelling

  3. #3
    Join Date
    Mar 2008
    Posts
    5

    Default

    Thanks for your reply. I'll try to give you some more information. I am running this on my pc. I have an itemreader that reads from a text file that is on my pc. Then the itemwriter uses some of the data from the text file to read a row from the keyTable, a DB2 table on the main frame. If it finds the row on the keyTable it updates a row on another DB2 Table. The select statement from the XML file that the QueryforObject uses is shown below:
    <property name="keyTableDao">
    <bean class="dao.JdbcKeyTableDaoImpl">
    <property name="dataSource" ref="dataSourceDB2" />
    <property name="fetch_Keytable_Sql"
    value="SELECT A.AL_ID, A.BL_ID, A.CL_ID,
    A.DL_ID, A.EL_ID, A.FL_NBR,
    A.GL, A.HL_NME
    from ${jdbc.default_schema}.KEYTABLE A
    where AL_ID=? AND BL_ID=?"/>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •