Hi,

I have the following Resource defined in context.xml

<Resource name="jdbc/MasterDB"
              auth="Container"
              driverClassName="oracle.jdbc.driver.OracleDriver"
              type="oracle.jdbc.pool.OracleDataSource"
              factory="oracle.jdbc.pool.OracleDataSourceFactory"
              description="Database Master DB Instance"
              maxActive="100"
              maxIdle="30"
              maxWait="5000"
              user="@@ORACLE_USER@@"
              password="@@ORACLE_USER_PASSWORD@@"

              loginTimeout="10"

              defaultAutoCommit="true"
              url="@@ORACLE_URL@@"
              validationQuery="select sysdate from dual"
              testOnBorrow="true"
              testWhileIdle="true"
              timeBetweenEvictionRunsMillis="300000"
              minEvictableIdleTimeMillis="1800000"
              />

where the user, password and url are all defined at install time and are not
important for this issue.

I use Hibernate on my application,  and define my hibernate.master.cfg.xml
as

<hibernate-configuration>
  <session-factory>
    <!-- The JNDI resource name for the Data Source defined in
tomcat/conf/context.xml -->
    <property
name="hibernate.connection.datasource">java:/comp/env/jdbc/MasterDB</property>
    <!-- The Hibernate Properties for this data source -->
    <property
name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
    <property name="hibernate.connection.autocommit">true</property>
    <property name="hibernate.cache.use_query_cache">false</property>
    <!-- <property name="hibernate.hbm2ddl.auto">validate</property> -->
    <property name="hibernate.jdbc.batch_size">0</property>
    <property name="hibernate.cache.use_second_level_cache">true</property>
    <property
name="hibernate.current_session_context_class">thread</property>
    <property
name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</property>
    <property
name="net.sf.ehcache.configurationResourceName">ehcache.xml</property>
  </session-factory>
</hibernate-configuration>

While the database is up an running, everything works fine in my web app
(webservices implemented with Spring framework)
But when the database is down, my clients timeout because my application
takes a lot of time to realize that the database is down (several minutes).

I want my web app to fail quickly if the DB is down (and either return some
useful error to the user)
I have been tried setting the property loginTimeout in my <Resource>, but it
seems that Tomcat is ignoring the property.

Originally I was using javax.sql.Datasource and the datasource factory was
defaulting to the DBCP BasicDataSourceFactory in my <Resource> declaration.
If I specified the loginTimeout property in the <Resource> with this
factory, the application was just unable to get a connection. (I forgot the
details, but this prompted me to use the
oracle.jdbc.pool.OracleDataSourceFactory and the corresponding data source,
oracle.jdbc.pool.OracleDataSource ).

Is Tomcat ignoring the loginTimeout property?


-Jorge

Reply via email to