Tuesday, September 18, 2012

clear statement cache in weblogic


This case confused me for hours today. I have a web service app hosted by weblogic v10.3.

A tester used an appId which is a part of input to call a web service. The server need to query database based on the appId passing from web service client. So it is ok system returned null because there was no data about the appId in database.
I added the appId in database, and tried to call again. It was suprised that system still returned null, while there was something returned if I tested it via junit class.

The only possibility is that server, whatever weblogic server or database server, returns historical data from cache.By default, weblogic set statement cache type as LRU and cache size as 10, refer to http://docs.oracle.com/cd/E12839_01/web.1111/e13737/jdbc_datasources.htm#JDBCA171 and oracle jdbc implemention caches the test result,refer to http://docs.oracle.com/cd/B10501_01/java.920/a96654/stmtcach.htm, so that is why I got unexpected result before clearing the statement cache in weblogic. (how to clear statement cache, refer to http://docs.oracle.com/cd/E16764_01/apirefs.1111/e13952/taskhelp/jdbc/jdbc_datasources/ClearStatementCache.html)