tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Unable to set loginTimeout on data sources defined in context.xml
Date Thu, 28 Jan 2010 20:23:27 GMT
Hash: SHA1


On 1/27/2010 5:40 PM, Jorge Medina wrote:
> 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"

I don't see any documentation that shows "loginTimeout" as being a valid
parameter for the <Resource> element.

Is this some OracleDataSourceFactory-specific parameter?

Looks like it:

(They're using the javadoc that shipped with Java 1.0 or something like
that... how delightful!)

> 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.

Try something like this in a test JSP:

  InitialContext ctx = new InitialContext();
  OracleDataSource ds =
DataSource loginTimeout = <%= ds.getLoginTimeout() %> seconds

If it says "10 seconds" then the property is being set on your
connection, and your problem is elsewhere.

> 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.

Probably because the "loginTimeout" property doesn't exist for

> (I forgot the
> details, but this prompted me to use the
> oracle.jdbc.pool.OracleDataSourceFactory and the corresponding data source,
> oracle.jdbc.pool.OracleDataSource ).

Try setting type="javax.jdbc.DataSource". By using the Oracle-specific
factory, I don't think it matters about the type, but it's tough for me
to understand the code for
org/apache/naming/factory/ out of context.

> Is Tomcat ignoring the loginTimeout property?

Most likely not. Tomcat's job is to pass that information on to the
DataSource that gets created by the Factory. Try the above code and see
what you get.

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message