You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Andrew Robson <an...@netscapeonline.co.uk> on 2001/09/01 00:18:18 UTC

Re: jdbc realms timing out database connection and not reconnecting

Hi,
  I bet the elapsed time between your last succesful login and the 
next attempt is 8 hours. There's a connection timeout variable in MySql which
controls this value but can't remember exact name off the top off my head.

Anyway to sort it out try adding - autoReconnect=true to the connectionURL 
string in server.xml i.e.
connectionURL="jdbc:mysql://localhost/dbName?autoReconnect=true"

btw, if you are going to use JDBCRealms you should 
upgrade to tomcat 3.2.3 because there is a large security hole 
in previous versions. 

- andrew

On Fri, 31 Aug 2001, you wrote:
> Everyone:
> 
> I am seeing some odd behavior using mysql database and jdbc realms.  When I
> first start up jakarta-tomcat it allows me to authenticate in and navigate
> my protected web area.  I can even exit and relogin within a couple of
> minutes later.  
> 
> When I go away for the day and come back it does not allow me to relogin.  I
> use the exact same usernames and passwords that I have used before.  It
> seems to be losing the database connection name and connection password that
> I have set in the server.xml file.  Do I need to configure the web.xml file
> for jdbc connectivity.  At present I am using a form to gather to login data
> and passing it to the jdbc realm to login the user in.  Is this the correct
> way of doing things?
> 
> Please see below for my present configuration.  Thanks in advance for any
> help that you can render.
> 
> 
> Tam
> 
> 
> 
> Software
> --------
> Redhat Linux 7.0 Kernel 2.4.0
> Mysql Version: mysql  Ver 11.15 Distrib 3.23.39, for pc-linux-gnu (i686)
> Jakarta-tomcat Version: 3.2.1
> Database Driver: mm.mysql 2.0.4
> 
> 
> -------------------------
> Successful Authentication
> -------------------------
> 2001-08-30 07:27:33 - ContextManager: JDBCRealm: JDBCRealm.roles: SELECT
> role_name FROM user_roles WHERE user_name = ?
> 
> 2001-08-30 07:27:33 - ContextManager: JDBCRealm: Auth ok, first role=tomcat
> 
> 2001-08-30 07:27:38 - ContextManager: JDBCRealm: Authentication successful
> for user tampham
> 
> 2001-08-30 07:27:38 - ContextManager: JDBCRealm: Auth ok, user=billybob
> ----------------------------
> 
> 
> ---------------------------
> Unsucessful authentication 
> ---------------------------
> 2001-08-31 01:09:45 - ContextManager: JDBCRealm: The  database connection is
> null or was found to be closed. Trying to re-open it.
>      
> 2001-08-31 01:09:45 - ContextManager: JDBCRealm: There was an SQLException
> while in authenticate: null
> 
> 2001-08-31 01:09:45 - ContextManager: JDBCRealm: SQLException:
> java.sql.SQLException: Invalid authorization spec
> ification: Access denied for user: 'nobody@localhost.localdomain' (Using
> password: NO)
> --------------------------
> 
> 
> 
> -----------------------------------
> Web.xml present config for authentication
> -----------------------------------  
> 
> <login-config>
>     <auth-method>FORM</auth-method>
>     <realm-name>Example Form-Based Authentication</realm-name>
>     <form-login-config>
>     <form-login-page>/jsp/login/login.jsp</form-login-page>
>     <form-error-page>/jsp/login/error.jsp</form-error-page>
>     </form-login-config>
> </login-config>
> --------------------------------------
> 
> 
> 
> ------------------------
> server.xml present config for jdbc realm configuration
> ------------------------ 
>      <RequestInterceptor
>      className="org.apache.tomcat.request.JDBCRealm"
>      debug="99"
>      driverName="org.gjt.mm.mysql.Driver"
>      connectionURL="jdbc:mysql://localhost/authority"
>      connectionName="mydatabaseuser"
>      connectionPassword="mydatabasepassword"
>      userTable="users" userNameCol="user_name" userCredCol="user_pass"
>      userRoleTable="user_roles" roleNameCol="role_name" />
> 
> 
> 
> Tam
--