3

I am migrating an application from WAS7 to Liberty.

The existing code usesWSCallHelper.clearStatementCache(connection) in some scenarios(example : package not found in case of procedure calls).

I found WSCallHelper doesn't exist in liberty server.

Could you please help me with an alternative solution for this in liberty. It can be either specific liberty or a general approach which will support all servers.

Biju N B
  • 67
  • 5

2 Answers2

1

It would be helpful to know more about the scenario where you need to call WSCallHelper.clearStatementCache(connection), but based on what you have described I'll assume that it is only called on an error path.

In Liberty, there is no API to programmatically clear the statement cache. However, cached statements will only be matched if a number of properties are the same such as: SQL string, RS holdability, schema, isolation level, and several others.

Why you don't need clearStatementCache:
The example scenario you described for calling clearStatementCache is when the package is not found in the DB, but the package should be reflected in either the SQL string or Schema. So, assuming that your application does not retry a failed SQL string, you should not need to invoke clearStatementCache at all.

If you really really want to clear the statement cache:
As defined by the JDBC spec, Statements are child objects of a Connection. So a creative way of clearing the statement cache would be to get rid of the connection with the bad statements. Invoking connection.close() may not accomplish this because connections can be pooled by the application server, but invoking connection.abort() will get rid of the underlying connection and therefore clear your statement cache.

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
1

We should also point out that if you want a more targeted approach and have a specific statement that you want removed from the cache (or to never go into the cache in the first place), you can use JDBC spec API java.sql.Statement.setPoolable(false) . Invoke this prior to closing the statement handle. The application server will not cache statements that are marked as poolable=false.

njr
  • 3,399
  • 9
  • 7