Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tomcat4: Authorization with mysql?

Status
Not open for further replies.

tol

Programmer
Oct 3, 2002
2
DE
Hi Tomcatusers,

this is my first time here, so I say hello to you :)
My english is not the best, but perhaps it's good enough to tell you my problems ;-)

I've installed tomcat4.1.12, build my first JSPs, installed the mysql-driver org.gjt.mm.mysql.Driver, connected to my Database, create some tables, insert rows ... all works fine :))

Now, I want to use the tomcat-user-authorization with mysql.

So, I create a DB tomcatusers and add the mysqluser tomcatadmin, set the passwd. I create the mysqlroles for this user and this DB: Allow ALL from ANY host for my user tomcatadmin - a little bit to much - I know ;-)
Than I create the tables user, roles and user_roles and insert a dummy-user and a dummy-role.
I configured the server.xml with :

<Realm className=&quot;org.apache.catalina.realm.JDBCRealm&quot; debug=&quot;99&quot;
driverName=&quot;org.gjt.mm.mysql.Driver&quot;
connectionURL=&quot;jdbc:mysql://localhost/tomcatusers?user=tomcatadmin;password=mypass&quot;
userTable=&quot;users&quot; userNameCol=&quot;user_name&quot;
userCredCol=&quot;user_pass&quot;
userRoleTable=&quot;user_roles&quot; roleNameCol=&quot;role_name&quot; />

Sooo ... now I restart the tomcat, but it dosn't work. Looking in the log catalina.out, there I read the following:

Exception opening database connection: java.sql.SQLException: General error: Access denied for user: '@localhost' to database 'tomcatusers'
[...]

Yeah! I didn't know, that @localhost is an user!! I thought it was a host ... ?! OK ... a bit confused.

Later I changed in the connectionURL the localhost to the ip:
from
&quot;jdbc:mysql://localhost/tomcatusers?user=tomcatadmin;password=mypass&quot;
to
&quot;jdbc:mysql://192.168.1.1/tomcatusers?user=tomcatadmin;password=mypass&quot;

Starting again an look in the logs. In catalina.out I read:
java.sql.SQLException: Invalid authorization specification:
Access denied for user: 'tomcatadmin;password@tomserv.mylan.de' (Using password: NO)

Ääähh? Is there an error in the stringmanipulation?? The username should really be tomcatadmin;password??? Or is the connectionURL incorrect?? Now: very confused :-(

Before I jump thru my window - is there anybody who can help me?

Tol
 
Some additional informations:

It seems that somthing is wrong with the connectionURL :-(

if I use this URL:
connectionURL=&quot;jdbc:mysql://localhost/users?user=tomcatadmin;password=mypass&quot;
I got the message:
Access denied for user: '@localhost' to database 'users'

or if I change to the ip-address:
connectionURL=&quot;jdbc:mysql://192.168.1.1/users?user=tomcatadmin;password=mypass&quot;
Access denied for user: 'tomcat;password@myhost.mylan.de' (Using password: NO)

I switch the user- and password-parameter:
connectionURL=&quot;jdbc:mysql://localhost/users?password=mypass;user=tomcatadmin&quot;
And now I got the message:
Access denied for user: 'nobody@localhost' (Using password: YES)
The change to the ip-address has the same result.

It seems, that the first parameter didn't stop at the &quot;;&quot;-sign and the second parameter was completely ignored.

Is this behavior an indication for a bug? ... or am I to daffy? ;-)

Some ideas?

Tol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top