miércoles, 28 de noviembre de 2007

JBoss stupid configuration errors

Why on earth the JBoss people doesn't warn about connection pooling? The stale connection are very common. What happens when the server has a smaller timeout time for the connection than the application server?
Answer: the connection becomes stale. It doesn't work anymore. Some drivers such as jTDS or DB2 jcc have this behavior.
The best thing you can do is add the following tag to your datasource XML:

<check-valid-connection-sql> SELECT 1</check-valid-connection-sql>

The SQL statement can be anything useful to you. Be sure not to do something crazy such as a join. The only requirement is that the SQL must execute OK, otherwise JBoss creates a fresh connection.

No hay comentarios: