-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jorge,
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. http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html http://tomcat.apache.org/tomcat-6.0-doc/config/globalresources.html http://commons.apache.org/dbcp/configuration.html Is this some OracleDataSourceFactory-specific parameter? Looks like it: http://www.oracle.com/technology/docs/tech/java/sqlj_jdbc/doc_library/javadoc/oracle.jdbc.pool.oracledatasource.html#setLoginTimeout%28int%29 (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 = (OracleDataSource)ctx.lookup("java:/comp/env/jdbc/MasterDB"); %> 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 BasicDataSourceFactory. > (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/ResourceFactory.java 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkth8j8ACgkQ9CaO5/Lv0PAexwCgo3uXG7uwwvXwVQDE/IklYjjj qJgAn3gKqVdyHZ7s3BmuXUFu6qNO2NYh =9zfV -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org