Announcement Announcement Module
No announcement yet.
jdbcTemplate query for object too slow Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

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

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

  • #2
    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, 07:57 PM. Reason: spelling


    • #3
      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=?"/>