Results 1 to 2 of 2

Thread: compilation of sql and errorcodes lookup slowing me down ?

  1. #1
    Join Date
    Sep 2004
    Posts
    23

    Default compilation of sql and errorcodes lookup slowing me down ?

    Hi,

    if I put verbose logging on I see the following messages for every sql call to the database :
    org.springframework.jdbc.object.SqlFunction - SQL operation not compiled before execution - invoking compile
    org.springframework.jdbc.support.SQLErrorCodesFact ory - Looking up default SQLErrorCodes for DataSource

    Can someone explain me what this means ? Can I avoid the compilation of the sql every time ? And why does it need to lookup errorcodes while I am using only one type of database ?

    Thanks,

    Henk

    Here is a piece of code :
    Code:
    public boolean rowExists(Timestamp tstamp, SynopDataBean bean) {
    		String sqlString = "SELECT COUNT(station_code) FROM SYNOPDATA WHERE timestamp=? AND station_code=?";
    		
    		SqlFunction checkNr = new SqlFunction(ds,sqlString);
    		Object[] params = new Object [] {tstamp, bean.getStationCode()};
    		checkNr.setTypes(new int[] { Types.TIMESTAMP, Types.NUMERIC});
    		if (checkNr.run(params) > 0) {
    			return true;
    		}
    		else {
    			return false;
    		}
    	}

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    JDBC objects are meant to be reusable. So long as you don't subclass them to create thread safety issues, the Spring superclasses are threadsafe.

    So you shouldn't be creating a new JDBC object instance each time. Yes, looking up metadata does have a cost, but it should be done once only.

    If a JDBC object needs to be created many times, consider setting a JdbcTemplate on it not a DataSource. That way you can use a single JdbcTemplate instance that caches the result of single metadata lookup.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Posting Permissions

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