Two Laptop Bag*
The moose likes JDBC and the fly likes JDBCRealm in Tomcat5.5 and SQLServer2005 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBCRealm in Tomcat5.5 and SQLServer2005" Watch "JDBCRealm in Tomcat5.5 and SQLServer2005" New topic
Author

JDBCRealm in Tomcat5.5 and SQLServer2005

Joe Crowson
Greenhorn

Joined: Jun 19, 2008
Posts: 8
Using Tomcat 5.5. Having trouble using JDBCRealm with SQLServer2005. Worked with SQLServer 2000. Now Tomcat will not start. Gives a NullPointerException and the following error, "at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:700)".

Realm tag looks like this.

<Realm className="org.apache.catalina.realm.JDBCRealm" debug="0" driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
connectionURL="jdbc:microsoft:sqlserver://xxxx;SelectMethod=cursor;databaseName=common" connectionName="common"
connectionPassword="xxxxxx" userTable="STUFF" userNameCol="USERID" userCredCol="PW"
userRoleTable="STUFF_RULES" roleNameCol="role_name"/>

Any help would be appreciated. Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I don't recall what the correct driver URLs are for either of those two databases, but I'm pretty sure they aren't the same. Did you change the driver URL to the correct URL for SQL Server 2005?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Also - which driver are you using? The old (discontinued) MS SQL 2000 driver is unlikely to work with 2005. Make sure you are using the new newer driver (or swap to jTDS).


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Joe Crowson
Greenhorn

Joined: Jun 19, 2008
Posts: 8
Originally posted by Paul Clapham:
I don't recall what the correct driver URLs are for either of those two databases, but I'm pretty sure they aren't the same. Did you change the driver URL to the correct URL for SQL Server 2005?


Sorry. I'm still new at this. Are you referring to the driver class name because I did switch that. I changed the connection url to point from the 2000 database to the 2005.
Thanks.
Joe Crowson
Greenhorn

Joined: Jun 19, 2008
Posts: 8
Originally posted by Paul Sturrock:
Also - which driver are you using? The old (discontinued) MS SQL 2000 driver is unlikely to work with 2005. Make sure you are using the new newer driver (or swap to jTDS).



Sorry. Still new at this. I'm using the sqljdbc.jar file. I believe this is for SQLServer 2005.

Thanks.
Joe Crowson
Greenhorn

Joined: Jun 19, 2008
Posts: 8
I am currently using version 1_1 of the driver. Tried using 1_2 with no luck.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Joe Crowson:
I changed the connection url to point from the 2000 database to the 2005.
Thanks.
And did you change to the "jdbc:microsoft:sqlserver" part of the URL from something else, or did you just leave it the way it was for 2000? Leaving it the way it was would have been wrong.
Joe Crowson
Greenhorn

Joined: Jun 19, 2008
Posts: 8
Here is an example of what I currently have.

connectionURL="jdbc:microsoft:sqlserver://99.99.99.999:9999;
integratedSecurity=false;DatabaseName=Promotions"

I didn't change the "jdbc:microsoft:sqlserver://" part, but I did change the number.

Thanks for your help.
Joe Crowson
Greenhorn

Joined: Jun 19, 2008
Posts: 8
Is the "jdbc:microsoft:sqlserver://" part supposed to change when connecting to SQLServer 2005? Any other suggestions?

Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yes, it's supposed to change. After I changed to SQL Server 2005 I stopped using the Microsoft driver (it had an SSL bug that I couldn't work around) and switched to the JTDS driver. So I don't have a working example of it here any more. I was hoping you would look in your documentation.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Here is the s005 JDBC driver documentation. The URL appears to need to be of the for:

jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]

I'd read through these docs and check what you've done.
[ June 24, 2008: Message edited by: Paul Sturrock ]
Joe Crowson
Greenhorn

Joined: Jun 19, 2008
Posts: 8
OK. Thanks guys. I think the fact that I have the word microsoft in the connectionURL is part of what is throwing me off.

Thanks again.
Joe Crowson
Greenhorn

Joined: Jun 19, 2008
Posts: 8
That was it!!! The correct syntax is "jdbc:sqlserver://99.99.99.999:9999;blah;blah;blah".
Thanks again for all your help.
Joe
 
 
subject: JDBCRealm in Tomcat5.5 and SQLServer2005
 
Similar Threads
How do you implement Web Services security?
Jdbc realm security
PDA...to SQlserver2005
Question about Tomcat Authentication
Question on Authentication and authorization