Subject Re: Tomcat + DBCP + FireBird
Author solusinfo_lms
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
>
> > I think you have 2 way to resolve this problem:
> > 1) Catch this exception and, if needed, get a new connection
from the
> > datasource
> > 2) (The best solution and the most adopted) Get a connection for
each
> > transaction/set of queries, make your queries and close the
connection
> > at the end.
>
> I suspect that the reason is different. Pool keeps connections open
> for "infinite" period of time (unless idle timeout is specified,
but
> let's forget it for now). However, it seems that your server is
> configured to drop open socket if no activity is happening during
XXX
> seconds (this is network configuration of the operating system, not
> Firebird). After that pool still believes that connection is open
> (because it did not close it), however socket is no longer valid.
Pool
> returns connection to the application, but the application cannot
do
> anything with it, returns it back. Connection is still believed to
be
> valid. This will happen until the pool is restarted.
>
> You have to check if DBCP provides a possibility to validate a
> connection before returning it to the application. JayBird 1.5 pool
> implementation has so called "pingStatement" and "pingInterval" -
> simple "SELECT CAST(1 as INTEGER) FROM rdb$database" is executed
each
> "pingInterval" seconds. There must be something similar in DBCP
too.
>
> Roman

Hi,
I now use JayBird 1.5 pool implementation (RC4) so i can
have "pingStatement" and "pingInterval" : i have to keep connection
to database alive because, for security purpose, there is a netasq
firewall that closes sockets that are inactives for X time (firewall
parameter).
So i want to use "pingInterval" to keep it alive but it doesn't seem
to work : i look at the network activity (with ethereal from debian
server that supports tomcat) and nothing happens : no packet
transmitted to FireBird server. Here are my parameters for JayBird
pool in server.xml (note, in my java code I get a connection - make
my queries - close my connection) :

<Resource name="jdbc/racine" auth="Container"
type="org.firebirdsql.pool.FBWrappingDataSource"/>
<ResourceParams name="jdbc/racine">
<parameter>
<name>factory</name>

<value>org.firebirdsql.pool.FBWrappingDataSource</value>
</parameter>
<parameter>
<name>maxConnections</name>
<value>10</value>
</parameter>
<parameter>
<name>minConnections</name>
<value>0</value>
</parameter>
<parameter>
<name>maxIdleTime</name>
<value>60000</value>
</parameter>
<parameter>
<name>userName</name>
<value>xxxxxxx</value>
</parameter>
<parameter>
<name>password</name>
<value>yyyyyyy</value>
</parameter>
<parameter>
<name>blockingTimeout</name>
<value>60000</value>
</parameter>
<parameter>
<name>database</name>
<value>SRVFB/3050:C:/dbfirebird/mydb.fdb</value>
</parameter>
<parameter>
<name>type</name>
<value>TYPE4</value>
</parameter>
<parameter>
<name>pingStatement</name>
<value>SELECT RC_PY_NOM FROM RC_PAYS WHERE
RC_PY_CODE='AD'</value>
</parameter>
<parameter>
<name>pingInterval</name>
<value>5</value>
</parameter>
</ResourceParams>

Best regards
Michel