Announcement Announcement Module
Collapse
No announcement yet.
compilation of sql and errorcodes lookup slowing me down ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment

    Working...
    X