Username and Passowrd configuration for a Tomcat Realm.

Alessandro A. Garbagnati

Additional info

I'm using tomcat 4.0.4. I've configured it to work with my mySqld at localhost just like the way in the Realm How-To in the Jakarta Tomcat Documentation.
This still it doesnt work. Somehow the username turns to '@'.

The realm configuration looks like this:

      <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
        userTable="users" userNameCol="user_name" userCredCol="user_pass"
        userRoleTable="user_roles" roleNameCol="role_name"/>
The error looks like this:
java.sql.SQLException: General error: Access denied for user: '@' to database 'jakarta'

It seems that the Realm isn't able to read the username from the jdbc url.
The solution could be found in the same document you were reading (Realm How-To), in the section JDBCRealm, that is to provide the username and the password as attributes of the Realm tag:
  connectionName The database username used to establish a JDBC connection.
  connectionPassword The database password used to establish a JDBC connection.