You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Dames, Kristopher J" <Kr...@Mercy.Net> on 2013/12/13 20:24:33 UTC

What if my database is unavailable at startup?

Hi,

I use tomcat 6 and have noticed if a database is not available when tomcat starts, tomcat will not try to connect once the database becomes available. Tomcat must be restarted to establish the database connection. What are best practices regarding this? Is there a way in tomcat to get it to automatically retry so I don't have to restart tomcat? I use DBCP but am willing to try some other pool.

--
Kris D.


This email contains information which may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of the addresses(s) named above.  If you have received this email in error, please contact the sender immediately.

Re: What if my database is unavailable at startup?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Dan,

On 12/13/13, 2:29 PM, Daniel Mikusa wrote:
> On Dec 13, 2013, at 2:24 PM, "Dames, Kristopher J"
> <Kr...@Mercy.Net> wrote:
> 
>> Hi,
>> 
>> I use tomcat 6
> 
> Which version specifically?
> 
>> and have noticed if a database is not available when tomcat
>> starts, tomcat will not try to connect once the database becomes
>> available. Tomcat must be restarted to establish the database
>> connection. What are best practices regarding this? Is there a
>> way in tomcat to get it to automatically retry so I don't have to
>> restart tomcat? I use DBCP but am willing to try some other
>> pool.
> 
> Can you include the <Resource /> tag for your connection pool?

Other important missing information:

1. What do you [Kris] expect to happen when the database becomes
available?

2. What actually happens when the database becomes available?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSq5T5AAoJEBzwKT+lPKRY1lgQAMUCI6sM7nFn5RZ0QsG58Lt2
SmJS98h/Grw0t58rQ78pXEVz68Jj3f/VAsky8a+6ENZOgu5DzskjNCpjq7S6jgsK
ZtgnAude7dsIlRrZi+DlD8oXPU0uo3f+SmA2redE7RZL6vXrVi3t2UUGZJGIOA/F
EgDhqZGP63O4JYHyk9JjwXKq6UVHZzYvjzzwp+4Nuf6n0AvOlFgUfqRI/TYyEhmt
0eH1/e0ZrpdXXyGBwVx5XdN/8PbhZGEVdhC6k/XdZTLwAHIRB3Y7a02QfovUA+jK
I1vJludiSA51ZafMPlCMQZHUXxOjk6joGMfYQ3y4wMSCRl/5mMIA9ETVzzi7C7HW
Ne8VQq3YmBmtmL34Ap/2Oof1hK5WWrDTNS7D+5bDTfq8ypr1ymZ2RJp+FNhkp+4C
p1cn10Rn23U1JbHEt55Exjp0mDOVbVMZpQzDgOX4JPeAREJa7czAS14FzPvHbLDR
CgobUVwBzjlG1/OLw4gVv+EjcvyFQIeA31+UT6YhHhWJvATiqHYoGTZKmEM2OMzO
IwAtUeasOKEIWulImMheckYaLPgp5Ce0BmUWGJ5RETbk8tmInRLGoZzxSKiSvQqC
YjJRYcfIzfFuGOhmShovRBm/8EvIUIg1IFhyRMb/BrR2IRf1IX+Cg+CCmHn9VgCL
6/Yqd8TBKp204ja8jwe7
=DgQm
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: What if my database is unavailable at startup?

Posted by Daniel Mikusa <dm...@gopivotal.com>.
On Dec 13, 2013, at 2:39 PM, "Dames, Kristopher J" <Kr...@Mercy.Net> wrote:

> Daniel,

When you reply, please include the previous email and don't top post.  Post inline like me or at the bottom.  This helps with the readability of this thread and it's the convention that we follow on this list.

> 
> I use tomcat 6.0.32. Here is an example Resource tag:
> 
> <Resource 
>    accessToUnderlyingConnectionAllowed="false"
>    auth="Container"
>    defaultAutoCommit="true"
>    defaultReadOnly="false" 
>    defaultSchema="xxxxx"
>    driverClassName="oracle.jdbc.driver.OracleDriver"
>    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>    initialSize="0" 
>    logAbandoned="false" 
>    maxActive="20"
>    maxIdle="8" 
>    maxOpenPreparedStatements="0" 
>    maxWait="5000"
>    minEvictableIdleTimeMillis="1800000" 
>    minIdle="5"
>    name="jdbc/xxxxx" 
>    numTestsPerEvictionRun="3"
>    password="xxxxx" 
>    poolPreparedStatements="false"
>    removeAbandoned="true" 
>    removeAbandonedTimeout="300"
>    testOnBorrow="true" 
>    testOnReturn="false"
>    testWhileIdle="true" 
>    timeBetweenEvictionRunsMillis="1800000"
>    type="javax.sql.DataSource"
>    url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"
>    username="xxxxx"
>    validationQuery="SELECT 1 FROM DUAL"
> />

Thanks. 

> and have noticed if a database is not available when tomcat starts, tomcat will not try to connect once the database becomes available. Tomcat must be restarted to establish the database connection.

Can you be more specific about this?  If the pool is empty, which I think it would be because you have "initialSize" set to zero and the database was down, it should try to create a new connection when the application requests the first connection from it.  What happens when your application requests a connection from the pool?  Does it fail with an exception?  Does it hang?  If it hangs, can you take some thread dumps?

Dan

> What are best practices regarding this? Is there a way in tomcat to get it to automatically retry so I don't have to restart tomcat? I use DBCP but am willing to try some other pool.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: What if my database is unavailable at startup?

Posted by "Propes, Barry L " <ba...@citi.com>.

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Friday, December 13, 2013 3:59 PM
To: Tomcat Users List
Subject: RE: What if my database is unavailable at startup?

> From: Propes, Barry L [mailto:barry.l.propes@citi.com] 
> Subject: RE: What if my database is unavailable at startup?

> I've never heard of these or seen these attributes either. What are they for?

> maxOpenPreparedStatements="0"
> accessToUnderlyingConnectionAllowed="false"

You could look in the doc:
http://commons.apache.org/proper/commons-dbcp/configuration.html

 - Chuck


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




Good enough. Although I'm not the one experiencing the problem. Mine works quite well without those two.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: What if my database is unavailable at startup?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Propes, Barry L [mailto:barry.l.propes@citi.com] 
> Subject: RE: What if my database is unavailable at startup?

> I've never heard of these or seen these attributes either. What are they for?

> maxOpenPreparedStatements="0"
> accessToUnderlyingConnectionAllowed="false"

You could look in the doc:
http://commons.apache.org/proper/commons-dbcp/configuration.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: What if my database is unavailable at startup?

Posted by "Propes, Barry L " <ba...@citi.com>.
I've never heard of these or seen these attributes either. What are they for?

-----Original Message-----
From: Jose María Zaragoza [mailto:demablogia@gmail.com] 
Sent: Friday, December 13, 2013 2:10 PM
To: Tomcat Users List
Subject: Re: What if my database is unavailable at startup?

With testOnBorrow="true" ( I think that is the default value in Tomcat
6 ) + validationQuery="SELECT 1 FROM DUAL" , that should work

I've never used

maxOpenPreparedStatements="0"
accessToUnderlyingConnectionAllowed="false"

what are they for ?




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: What if my database is unavailable at startup?

Posted by "Dames, Kristopher J" <Kr...@Mercy.Net>.

> -----Original Message-----
> From: Jose María Zaragoza [mailto:demablogia@gmail.com]
> Sent: Friday, December 13, 2013 2:33 PM
> To: Tomcat Users List
> Subject: Re: What if my database is unavailable at startup?
> 
> 2013/12/13 Dames, Kristopher J <Kr...@mercy.net>:
> >> With testOnBorrow="true" ( I think that is the default value in Tomcat
> >> 6 ) + validationQuery="SELECT 1 FROM DUAL" , that should work
> >>
> >
> > So you are saying my configuration should work as-is to allow Tomcat to
> create a database connection pool to a database that was unavailable when
> Tomcat was started?
> 
> 
> Yes , I do it and it works
> But I dont use some parameters like maxOpenPreparedStatements ,
> accessToUnderlyingConnectionAllowed
> Furthermore, I use default values for testOnXXX
> The others , at first sight, are similar
> 

Tomcat appears to be working properly. Another webapp in the same Tomcat instance does recover once the database becomes available. The one that does not is using an older Oracle driver. In addition, both are JRuby on Rails webapps and the non-working one is using an older version of Rails. So the issue seems to be with the webapp instead of with Tomcat itself. Thank you all for the input and direction!

--
Kris Dames



> >> I've never used
> >>
> >> maxOpenPreparedStatements="0"
> >> accessToUnderlyingConnectionAllowed="false"
> >>
> >> what are they for ?
> >>
> >
> > maxOpenPreparedStatements: The maximum number of open statements that can be
> allocated from the statement pool at the same time
> > accessToUnderlyingConnectionAllowed: Allows the raw physical connection to
> the database to be accessed by the webapp
> >
> > This email contains information which may be PROPRIETARY IN NATURE OR
> OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of
> the addresses(s) named above.  If you have received this email in error,
> please contact the sender immediately.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

This email contains information which may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of the addresses(s) named above.  If you have received this email in error, please contact the sender immediately.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: What if my database is unavailable at startup?

Posted by Jose María Zaragoza <de...@gmail.com>.
2013/12/13 Dames, Kristopher J <Kr...@mercy.net>:
>> With testOnBorrow="true" ( I think that is the default value in Tomcat
>> 6 ) + validationQuery="SELECT 1 FROM DUAL" , that should work
>>
>
> So you are saying my configuration should work as-is to allow Tomcat to create a database connection pool to a database that was unavailable when Tomcat was started?


Yes , I do it and it works
But I dont use some parameters like maxOpenPreparedStatements ,
accessToUnderlyingConnectionAllowed
Furthermore, I use default values for testOnXXX
The others , at first sight, are similar


>
>
>
>> I've never used
>>
>> maxOpenPreparedStatements="0"
>> accessToUnderlyingConnectionAllowed="false"
>>
>> what are they for ?
>>
>
> maxOpenPreparedStatements: The maximum number of open statements that can be allocated from the statement pool at the same time
> accessToUnderlyingConnectionAllowed: Allows the raw physical connection to the database to be accessed by the webapp
>
> This email contains information which may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of the addresses(s) named above.  If you have received this email in error, please contact the sender immediately.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: What if my database is unavailable at startup?

Posted by "Dames, Kristopher J" <Kr...@Mercy.Net>.
> With testOnBorrow="true" ( I think that is the default value in Tomcat
> 6 ) + validationQuery="SELECT 1 FROM DUAL" , that should work
> 

So you are saying my configuration should work as-is to allow Tomcat to create a database connection pool to a database that was unavailable when Tomcat was started?


> I've never used
> 
> maxOpenPreparedStatements="0"
> accessToUnderlyingConnectionAllowed="false"
> 
> what are they for ?
> 

maxOpenPreparedStatements: The maximum number of open statements that can be allocated from the statement pool at the same time
accessToUnderlyingConnectionAllowed: Allows the raw physical connection to the database to be accessed by the webapp

This email contains information which may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of the addresses(s) named above.  If you have received this email in error, please contact the sender immediately.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: What if my database is unavailable at startup?

Posted by Jose María Zaragoza <de...@gmail.com>.
With testOnBorrow="true" ( I think that is the default value in Tomcat
6 ) + validationQuery="SELECT 1 FROM DUAL" , that should work

I've never used

maxOpenPreparedStatements="0"
accessToUnderlyingConnectionAllowed="false"

what are they for ?




2013/12/13 Dames, Kristopher J <Kr...@mercy.net>:
> Daniel,
>
> I use tomcat 6.0.32. Here is an example Resource tag:
>
> <Resource
>     accessToUnderlyingConnectionAllowed="false"
>     auth="Container"
>     defaultAutoCommit="true"
>     defaultReadOnly="false"
>     defaultSchema="xxxxx"
>     driverClassName="oracle.jdbc.driver.OracleDriver"
>     factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>     initialSize="0"
>     logAbandoned="false"
>     maxActive="20"
>     maxIdle="8"
>     maxOpenPreparedStatements="0"
>     maxWait="5000"
>     minEvictableIdleTimeMillis="1800000"
>     minIdle="5"
>     name="jdbc/xxxxx"
>     numTestsPerEvictionRun="3"
>     password="xxxxx"
>     poolPreparedStatements="false"
>     removeAbandoned="true"
>     removeAbandonedTimeout="300"
>     testOnBorrow="true"
>     testOnReturn="false"
>     testWhileIdle="true"
>     timeBetweenEvictionRunsMillis="1800000"
>     type="javax.sql.DataSource"
>     url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"
>     username="xxxxx"
>     validationQuery="SELECT 1 FROM DUAL"
> />
>
> This email contains information which may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of the addresses(s) named above.  If you have received this email in error, please contact the sender immediately.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: What if my database is unavailable at startup?

Posted by "Dames, Kristopher J" <Kr...@Mercy.Net>.
> can/should we assume that your URL is referencing a database on a different
> machine, same network/intranet/LAN?
>
> >  url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"
>
> it seems as though OP is referencing a database somewhere on the 'internet'.

The database server is on the same network, different machine.


--
Kris D.


This email contains information which may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of the addresses(s) named above.  If you have received this email in error, please contact the sender immediately.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: What if my database is unavailable at startup?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Barry,

On 12/23/13, 4:14 PM, Propes, Barry L wrote:
> 
> -----Original Message----- From: Tomcat Random
> [mailto:tomcat.random@gmail.com] Sent: Monday, December 23, 2013
> 2:56 PM To: Tomcat Users List Subject: Re: What if my database is
> unavailable at startup?
> 
> Barry,
> 
> You have testOnBorrow="true" without a validation query. That means
> the line is useless. Or as the docs say:* NOTE - for a true value
> to have any effect, the validationQuery parameter must be set to a
> non-null string*
> 
> Best, Alec
> 
> 
> On Mon, Dec 16, 2013 at 10:07 AM, Propes, Barry L 
> <ba...@citi.com>wrote:
> 
>> 
>> 
>> -----Original Message----- From: Howard W. Smith, Jr.
>> [mailto:smithh032772@gmail.com] Sent: Friday, December 13, 2013
>> 4:23 PM To: Tomcat Users List Subject: Re: What if my database is
>> unavailable at startup?
>> 
>> OP,
>> 
>> On Fri, Dec 13, 2013 at 2:24 PM, Dames, Kristopher J < 
>> Kristopher.Dames@mercy.net> wrote:
>> 
>>> I use tomcat 6 and have noticed if a database is not available
>>> when tomcat starts, tomcat will not try to connect once the
>>> database becomes
>> available.
>>> Tomcat must be restarted to establish the database connection.
>>> What are best practices regarding this? Is there a way in
>>> tomcat to get it to automatically retry so I don't have to
>>> restart tomcat? I use DBCP but am willing to try some other
>>> pool.
>> 
>> 
>> Barry,
>> 
>> On Fri, Dec 13, 2013 at 4:59 PM, Propes, Barry L 
>> <barry.l.propes@citi.com
>>> wrote:
>> 
>>> I use DBCP and Oracle as well, and am also on Tomcat 6 -
>>> 6.0.26. Take a look at mine, as I have NO trouble with it, and
>>> see if you can configure it similarly with success. NOTE -
>>> remove those other two parameters that Jose mentions in a prior
>>> email.
>>> 
>>> <Resource auth="Container" description="mytomcatapp" 
>>> name="jdbc/myoracle" type="javax.sql.DataSource" 
>>> driverClassName="oracle.jdbc.driver.OracleDriver" 
>>> username="username" password="password" 
>>> url="jdbc:oracle:thin:@cgnrdb1p:1648:SERVNAME" maxIdle="30" 
>>> maxWait="10000" maxActive="10" testOnBorrow="true" 
>>> timeBetweenEvictionRunsMillis="-1" 
>>> minEvictableIdleTimeMillis="28800" 
>>> poolPreparedStatements="true" removeAbandoned="true" 
>>> removeAbandonedTimeout="300" logAbandoned="false"/>
>>> 
>> 
>> are you suggesting that your (or a correct(ed)) <Resource> will
>> solve the problem stated in OP (above)?
>> 
>> can/should we assume that your URL is referencing a database on a
>>  different machine, same network/intranet/LAN?
>> 
>>> url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"
>> 
>> it seems as though OP is referencing a database somewhere on the
>>  'internet'.
>> 
>> --------------------------------------------------------------
>> 
>> Oh ok. Yes, mine is on the same network, through an intranet. 
>> Different machine, but same network. If that helps.
>> 
>> 
> 
> 
> OK, thanks for the heads up. I'll remove that attribute as I really
> don't need it.

... and you'll get the default, which is .... (wait for it):

   testOnBorrow="true"

Are you sure you'll never get a dropped Connection?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSuLBRAAoJEBzwKT+lPKRYuq4P/2TPBX4rXZ+UXe4b/0Ra6O7e
jkhNZT6IFC3lsFRXAdpdgNc3Cj0cudLzlfqViOwwAVbWcUSL8SXTaU72Ty9r5rM9
rn2LOBLgn5zIPVTsW25+/AUv+8Ffxjse3tgeWBCAMglxAt6qBtWJoOUEWTw/3UXF
m3e8TnKSkpMnLPPUYCWvXoJbp8oBNx6gvBtDLtwMewNZ86E2zzxmdmUPeQA9oJQ9
FHQr6WX8H7f5RjR0oEc9fOLiAHYkxmFDLzsNgXP7aH9VeymNCms9iMc54Ey8SnFP
9Rlthn6Gopg9zOCwgGBJRk3CEQajWVmEOalGCpr4KDt83NMC59OhDwZosBL/k/P9
2x0oEQHW3/zyDT+LOGX1Zphb8OnawUhZ6/ht9Y/QEcmefWsMEBU4tIjSjOLpnCfB
KtMhcl4iceTfpOmuFsR7GvwPhJ3JjpfbnPa+WO+W9qFPXeiCyaJK14xPMZo4T8Tu
27V5t8wrbjl57DBrQUScCYsHvOiSodqlI5u1CudojUo6eq8FSPabVHW8utr+S6k9
6cUHcjweqrasXEOILKYuC5v0P+/aTdhJqYL8JK9Jd7Mcn5tzgzTj1r8CWAFPaP40
YB8Psa/Xv0KwQPHB8jcUNQlP4af9TkfVuG4pqzpJ/2YxSXi2/a6uIo0YaN0QqCDB
6XhbjMPhW+TqiBm/oKaW
=AzYx
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: What if my database is unavailable at startup?

Posted by "Propes, Barry L " <ba...@citi.com>.
-----Original Message-----
From: Tomcat Random [mailto:tomcat.random@gmail.com] 
Sent: Monday, December 23, 2013 2:56 PM
To: Tomcat Users List
Subject: Re: What if my database is unavailable at startup?

Barry,

You have testOnBorrow="true" without a validation query. That means the line is useless. Or as the docs say:* NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string*

Best,
Alec


On Mon, Dec 16, 2013 at 10:07 AM, Propes, Barry L
<ba...@citi.com>wrote:

>
>
> -----Original Message-----
> From: Howard W. Smith, Jr. [mailto:smithh032772@gmail.com]
> Sent: Friday, December 13, 2013 4:23 PM
> To: Tomcat Users List
> Subject: Re: What if my database is unavailable at startup?
>
> OP,
>
> On Fri, Dec 13, 2013 at 2:24 PM, Dames, Kristopher J < 
> Kristopher.Dames@mercy.net> wrote:
>
> > I use tomcat 6 and have noticed if a database is not available when 
> > tomcat starts, tomcat will not try to connect once the database 
> > becomes
> available.
> > Tomcat must be restarted to establish the database connection. What 
> > are best practices regarding this? Is there a way in tomcat to get 
> > it to automatically retry so I don't have to restart tomcat? I use 
> > DBCP but am willing to try some other pool.
>
>
> Barry,
>
> On Fri, Dec 13, 2013 at 4:59 PM, Propes, Barry L 
> <barry.l.propes@citi.com
> >wrote:
>
> > I use DBCP and Oracle as well, and am also on Tomcat 6 - 6.0.26. 
> > Take a look at mine, as I have NO trouble with it, and see if you 
> > can configure it similarly with success. NOTE - remove those other 
> > two parameters that Jose mentions in a prior email.
> >
> >   <Resource
> >     auth="Container"
> >     description="mytomcatapp"
> >     name="jdbc/myoracle"
> >     type="javax.sql.DataSource"
> >     driverClassName="oracle.jdbc.driver.OracleDriver"
> >     username="username"
> >     password="password"
> >     url="jdbc:oracle:thin:@cgnrdb1p:1648:SERVNAME"
> >     maxIdle="30"
> >     maxWait="10000"
> >     maxActive="10"
> >     testOnBorrow="true"
> >     timeBetweenEvictionRunsMillis="-1"
> >     minEvictableIdleTimeMillis="28800"
> >     poolPreparedStatements="true"
> >     removeAbandoned="true"
> >     removeAbandonedTimeout="300"
> >     logAbandoned="false"/>
> >
>
> are you suggesting that your (or a correct(ed)) <Resource> will solve 
> the problem stated in OP (above)?
>
> can/should we assume that your URL is referencing a database on a 
> different machine, same network/intranet/LAN?
>
> >  url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"
>
> it seems as though OP is referencing a database somewhere on the 
> 'internet'.
>
> --------------------------------------------------------------
>
> Oh ok. Yes, mine is on the same network, through an intranet. 
> Different machine, but same network. If that helps.
>
>


OK, thanks for the heads up. I'll remove that attribute as I really don't need it.


>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: What if my database is unavailable at startup?

Posted by Tomcat Random <to...@gmail.com>.
Barry,

You have testOnBorrow="true" without a validation query. That means the
line is useless. Or as the docs say:* NOTE - for a true value to have any
effect, the validationQuery parameter must be set to a non-null string*

Best,
Alec


On Mon, Dec 16, 2013 at 10:07 AM, Propes, Barry L
<ba...@citi.com>wrote:

>
>
> -----Original Message-----
> From: Howard W. Smith, Jr. [mailto:smithh032772@gmail.com]
> Sent: Friday, December 13, 2013 4:23 PM
> To: Tomcat Users List
> Subject: Re: What if my database is unavailable at startup?
>
> OP,
>
> On Fri, Dec 13, 2013 at 2:24 PM, Dames, Kristopher J <
> Kristopher.Dames@mercy.net> wrote:
>
> > I use tomcat 6 and have noticed if a database is not available when
> > tomcat starts, tomcat will not try to connect once the database becomes
> available.
> > Tomcat must be restarted to establish the database connection. What
> > are best practices regarding this? Is there a way in tomcat to get it
> > to automatically retry so I don't have to restart tomcat? I use DBCP
> > but am willing to try some other pool.
>
>
> Barry,
>
> On Fri, Dec 13, 2013 at 4:59 PM, Propes, Barry L <barry.l.propes@citi.com
> >wrote:
>
> > I use DBCP and Oracle as well, and am also on Tomcat 6 - 6.0.26. Take
> > a look at mine, as I have NO trouble with it, and see if you can
> > configure it similarly with success. NOTE - remove those other two
> > parameters that Jose mentions in a prior email.
> >
> >   <Resource
> >     auth="Container"
> >     description="mytomcatapp"
> >     name="jdbc/myoracle"
> >     type="javax.sql.DataSource"
> >     driverClassName="oracle.jdbc.driver.OracleDriver"
> >     username="username"
> >     password="password"
> >     url="jdbc:oracle:thin:@cgnrdb1p:1648:SERVNAME"
> >     maxIdle="30"
> >     maxWait="10000"
> >     maxActive="10"
> >     testOnBorrow="true"
> >     timeBetweenEvictionRunsMillis="-1"
> >     minEvictableIdleTimeMillis="28800"
> >     poolPreparedStatements="true"
> >     removeAbandoned="true"
> >     removeAbandonedTimeout="300"
> >     logAbandoned="false"/>
> >
>
> are you suggesting that your (or a correct(ed)) <Resource> will solve the
> problem stated in OP (above)?
>
> can/should we assume that your URL is referencing a database on a
> different machine, same network/intranet/LAN?
>
> >  url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"
>
> it seems as though OP is referencing a database somewhere on the
> 'internet'.
>
> --------------------------------------------------------------
>
> Oh ok. Yes, mine is on the same network, through an intranet. Different
> machine, but same network. If that helps.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: What if my database is unavailable at startup?

Posted by "Propes, Barry L " <ba...@citi.com>.

-----Original Message-----
From: Howard W. Smith, Jr. [mailto:smithh032772@gmail.com] 
Sent: Friday, December 13, 2013 4:23 PM
To: Tomcat Users List
Subject: Re: What if my database is unavailable at startup?

OP,

On Fri, Dec 13, 2013 at 2:24 PM, Dames, Kristopher J < Kristopher.Dames@mercy.net> wrote:

> I use tomcat 6 and have noticed if a database is not available when 
> tomcat starts, tomcat will not try to connect once the database becomes available.
> Tomcat must be restarted to establish the database connection. What 
> are best practices regarding this? Is there a way in tomcat to get it 
> to automatically retry so I don't have to restart tomcat? I use DBCP 
> but am willing to try some other pool.


Barry,

On Fri, Dec 13, 2013 at 4:59 PM, Propes, Barry L <ba...@citi.com>wrote:

> I use DBCP and Oracle as well, and am also on Tomcat 6 - 6.0.26. Take 
> a look at mine, as I have NO trouble with it, and see if you can 
> configure it similarly with success. NOTE - remove those other two 
> parameters that Jose mentions in a prior email.
>
>   <Resource
>     auth="Container"
>     description="mytomcatapp"
>     name="jdbc/myoracle"
>     type="javax.sql.DataSource"
>     driverClassName="oracle.jdbc.driver.OracleDriver"
>     username="username"
>     password="password"
>     url="jdbc:oracle:thin:@cgnrdb1p:1648:SERVNAME"
>     maxIdle="30"
>     maxWait="10000"
>     maxActive="10"
>     testOnBorrow="true"
>     timeBetweenEvictionRunsMillis="-1"
>     minEvictableIdleTimeMillis="28800"
>     poolPreparedStatements="true"
>     removeAbandoned="true"
>     removeAbandonedTimeout="300"
>     logAbandoned="false"/>
>

are you suggesting that your (or a correct(ed)) <Resource> will solve the problem stated in OP (above)?

can/should we assume that your URL is referencing a database on a different machine, same network/intranet/LAN?

>  url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"

it seems as though OP is referencing a database somewhere on the 'internet'.

--------------------------------------------------------------

Oh ok. Yes, mine is on the same network, through an intranet. Different machine, but same network. If that helps.





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: What if my database is unavailable at startup?

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
OP,

On Fri, Dec 13, 2013 at 2:24 PM, Dames, Kristopher J <
Kristopher.Dames@mercy.net> wrote:

> I use tomcat 6 and have noticed if a database is not available when tomcat
> starts, tomcat will not try to connect once the database becomes available.
> Tomcat must be restarted to establish the database connection. What are
> best practices regarding this? Is there a way in tomcat to get it to
> automatically retry so I don't have to restart tomcat? I use DBCP but am
> willing to try some other pool.


Barry,

On Fri, Dec 13, 2013 at 4:59 PM, Propes, Barry L <ba...@citi.com>wrote:

> I use DBCP and Oracle as well, and am also on Tomcat 6 - 6.0.26. Take a
> look at mine, as I have NO trouble with it, and see if you can configure it
> similarly with success. NOTE - remove those other two parameters that Jose
> mentions in a prior email.
>
>   <Resource
>     auth="Container"
>     description="mytomcatapp"
>     name="jdbc/myoracle"
>     type="javax.sql.DataSource"
>     driverClassName="oracle.jdbc.driver.OracleDriver"
>     username="username"
>     password="password"
>     url="jdbc:oracle:thin:@cgnrdb1p:1648:SERVNAME"
>     maxIdle="30"
>     maxWait="10000"
>     maxActive="10"
>     testOnBorrow="true"
>     timeBetweenEvictionRunsMillis="-1"
>     minEvictableIdleTimeMillis="28800"
>     poolPreparedStatements="true"
>     removeAbandoned="true"
>     removeAbandonedTimeout="300"
>     logAbandoned="false"/>
>

are you suggesting that your (or a correct(ed)) <Resource> will solve the
problem stated in OP (above)?

can/should we assume that your URL is referencing a database on a different
machine, same network/intranet/LAN?

>  url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"

it seems as though OP is referencing a database somewhere on the 'internet'.

RE: What if my database is unavailable at startup?

Posted by "Propes, Barry L " <ba...@citi.com>.

-----Original Message-----
From: Dames, Kristopher J [mailto:Kristopher.Dames@Mercy.Net] 
Sent: Friday, December 13, 2013 1:39 PM
To: Tomcat Users List
Subject: RE: What if my database is unavailable at startup?

Daniel,

I use tomcat 6.0.32. Here is an example Resource tag:

<Resource 
    accessToUnderlyingConnectionAllowed="false"
    auth="Container"
    defaultAutoCommit="true"
    defaultReadOnly="false" 
    defaultSchema="xxxxx"
    driverClassName="oracle.jdbc.driver.OracleDriver"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    initialSize="0" 
    logAbandoned="false" 
    maxActive="20"
    maxIdle="8" 
    maxOpenPreparedStatements="0" 
    maxWait="5000"
    minEvictableIdleTimeMillis="1800000" 
    minIdle="5"
    name="jdbc/xxxxx" 
    numTestsPerEvictionRun="3"
    password="xxxxx" 
    poolPreparedStatements="false"
    removeAbandoned="true" 
    removeAbandonedTimeout="300"
    testOnBorrow="true" 
    testOnReturn="false"
    testWhileIdle="true" 
    timeBetweenEvictionRunsMillis="1800000"
    type="javax.sql.DataSource"
    url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"
    username="xxxxx"
    validationQuery="SELECT 1 FROM DUAL"
/>


I use DBCP and Oracle as well, and am also on Tomcat 6 - 6.0.26. Take a look at mine, as I have NO trouble with it, and see if you can configure it similarly with success. NOTE - remove those other two parameters that Jose mentions in a prior email.

  <Resource
    auth="Container"
    description="mytomcatapp"
    name="jdbc/myoracle"
    type="javax.sql.DataSource"
    driverClassName="oracle.jdbc.driver.OracleDriver"
    username="username"
    password="password"
    url="jdbc:oracle:thin:@cgnrdb1p:1648:SERVNAME"
    maxIdle="30"
    maxWait="10000"
    maxActive="10"
    testOnBorrow="true"
    timeBetweenEvictionRunsMillis="-1"
    minEvictableIdleTimeMillis="28800"
    poolPreparedStatements="true"
    removeAbandoned="true"
    removeAbandonedTimeout="300"
    logAbandoned="false"/>
    




This email contains information which may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of the addresses(s) named above.  If you have received this email in error, please contact the sender immediately.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: What if my database is unavailable at startup?

Posted by "Dames, Kristopher J" <Kr...@Mercy.Net>.
Daniel,

I use tomcat 6.0.32. Here is an example Resource tag:

<Resource 
    accessToUnderlyingConnectionAllowed="false"
    auth="Container"
    defaultAutoCommit="true"
    defaultReadOnly="false" 
    defaultSchema="xxxxx"
    driverClassName="oracle.jdbc.driver.OracleDriver"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    initialSize="0" 
    logAbandoned="false" 
    maxActive="20"
    maxIdle="8" 
    maxOpenPreparedStatements="0" 
    maxWait="5000"
    minEvictableIdleTimeMillis="1800000" 
    minIdle="5"
    name="jdbc/xxxxx" 
    numTestsPerEvictionRun="3"
    password="xxxxx" 
    poolPreparedStatements="false"
    removeAbandoned="true" 
    removeAbandonedTimeout="300"
    testOnBorrow="true" 
    testOnReturn="false"
    testWhileIdle="true" 
    timeBetweenEvictionRunsMillis="1800000"
    type="javax.sql.DataSource"
    url="jdbc:oracle:thin:@xxxxx.yyyyy.com:1521:xxxxx"
    username="xxxxx"
    validationQuery="SELECT 1 FROM DUAL"
/>

This email contains information which may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of the addresses(s) named above.  If you have received this email in error, please contact the sender immediately.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: What if my database is unavailable at startup?

Posted by Daniel Mikusa <dm...@gopivotal.com>.
On Dec 13, 2013, at 2:24 PM, "Dames, Kristopher J" <Kr...@Mercy.Net> wrote:

> Hi,
> 
> I use tomcat 6

Which version specifically?

> and have noticed if a database is not available when tomcat starts, tomcat will not try to connect once the database becomes available. Tomcat must be restarted to establish the database connection. What are best practices regarding this? Is there a way in tomcat to get it to automatically retry so I don't have to restart tomcat? I use DBCP but am willing to try some other pool.

Can you include the <Resource /> tag for your connection pool?

Dan

> 
> --
> Kris D.
> 
> 
> This email contains information which may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE and is intended only for the use of the addresses(s) named above.  If you have received this email in error, please contact the sender immediately.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org