Why Derby does not use property 'currentShema' from my WAS datasource?

余生颓废 提交于 2019-12-02 12:26:01

I have found a solution, specific to my use case as the fix is done with WebSphere configuration.

Solution: Configure the datasource to automatically execute an SQL query to validate a new connection pooled from this datasource. The SQL query is

SET CURRENT SCHEMA MY_SCHEMA

where 'MY_SCHEMA' is specific to each datasource.

This is of course configurable with wsadmin scripting by updating:

  • J2EEResourceProperty 'preTestSQLString' on the datasource, with value = SQL query
  • 'testConnections' property of datasource pool with value 'true'

Without specific server environment like WebSphere to auto execute SQL query on a fresh connection pooled, i fear this is not possible, unless doing it in the code with an EntityManager producer. But that mean you have to write code specific to your environments, and this is not... nice.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!