You need to set "validationQuery" on the BasicDataSource definition in order
to automatically handle lost database connections. For MySQL you can use
"select 1" and for Oracle you can use "select 0 from dual"

Sanjiv

On Fri, May 1, 2009 at 12:40 PM, Albert.Chao <albert.c...@groupdca.com>wrote:

>  Matt,
>
>
>
> The issue is sometime we need to shut down db to do maintenance work.
>
> Once the database back on, the appfuse/tomcat can’t find connection to
> database.
>
> We need to restart appfuse/tomcat to let connection pool work again.
>
>
>
> Is it always necessary to restart app server?
>
> How to configure appfuse to avoid restarting app server?
>
>
>
> Albert
>
>
>  ------------------------------
>
> *From:* Matt Raible [mailto:m...@raibledesigns.com]
> *Sent:* Friday, May 01, 2009 12:24 PM
> *To:* users@appfuse.dev.java.net
> *Subject:* Re: [appfuse-user] gracely handle database disconnection
>
>
>
> How does the database get disconnected? Unfortunately, I'm not sure how to
> reconnect when it fails if it doesn't already happen automatically.
>
> On Fri, May 1, 2009 at 10:09 AM, Albert.Chao <albert.c...@groupdca.com>
> wrote:
>
> Hi all,
>
>
>
> Could someone help me to solve “disconnected database when user login”?
>
>
>
> I have these values in applicationConext-resource.xml.
>
> I started webserver / database then shutdown database to do this test case.
>
> When I login, I still get
>
>
>
> org.springframework.transaction.CannotCreateTransactionException: Could not 
> open Hibernate Session for transaction; nested exception is 
> org.hibernate.exception.JDBCConnectionException: Cannot open connection
>
>          at 
> org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:550)
>
>
>
> I have put   <global-exception-mappings> <exception-mapping
> exception="java.lang.Exception" result="home"/>
>
> It still gives me stack error
>
>
>
>
>
> How to solve this issue?
>
>
>
> applicationConext-resource.xml
>
>   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
> destroy-method="close">
>
>         <property name="driverClassName" value="${jdbc.driverClassName}"/>
>
>         <property name="url" value="${jdbc.url}"/>
>
>         <property name="username" value="${jdbc.username}"/>
>
>         <property name="password" value="${jdbc.password}"/>
>
>         <property name="maxActive" value="100"/>
>
>         <property name="maxWait" value="1000"/>
>
>         <property name="poolPreparedStatements" value="true"/>
>
>         <property name="defaultAutoCommit" value="true"/>
>
>         <property name="validationQuery" value="select 1 from dual"/>
>
>         <property name="testOnBorrow" value="true"/>
>
>     </bean>
>
>
>

Reply via email to