Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem connecting to sqlserver from Tomcat

 
Mike Aguilar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm very new at this, so please be patient...

I'm trying to connect to a sqlserver database with Tomcat 5.0. I've taken over a project which someone else built and I'm having problems.

In my server.xml file I have this:

<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="com.microsoft.jdbc.sqlserver.SqlServerDriver"
connectionURL="jdbc:microsoft:sqlserver://server-west:1433;databasename=dbcal;SelectMethod=cursor"
connectionName="dbcal" connectionPassword="dbcal"
userTable="users" userNameCol="user_name" userCredCol="password"
userRoleTable="user_roles" roleNameCol="role" />

I have downloaded and installed the sqlserver driver from ms and copied it into the Tomcat 5.0\common\lib folder (and also to the Tomcat 5.0\shared\lib folder just for good measure).

I created an application role in sqlserver with the username and password of "dbcal".

And I'm getting the error:

2004-10-07 13:09:58 JDBCRealm[Catalina]: Exception opening database connection
java.sql.SQLException: com.microsoft.jdbc.sqlserver.SqlServerDriver
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:589)
at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:663)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1075)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

Can anyone point me in the right direction?

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65114
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Mike.

Since this is very Tomcat-focused, I'm going to move it to our Tomcat forum where it will get the attention of Tomcat users.
 
Scott Dunbar
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,
Can you post more of the stack trace? It looks like Tomcat is finding the classes but something else is happening.

Also, remember that the MS/SQL driver is distributed as three jar files - they all have to exists.
[ October 07, 2004: Message edited by: Scott Dunbar ]
 
Mike Aguilar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Scott,

Thanks for your reply.

I've got these three files: msbase.jar, mssqlserver.jar, and msutil.jar


And here's more of the error:

2004-10-07 13:09:58 JDBCRealm[Catalina]: Exception opening database connection
java.sql.SQLException: com.microsoft.jdbc.sqlserver.SqlServerDriver
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:589)
at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:663)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1075)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

2004-10-07 13:10:47 JDBCRealm[Catalina]: Exception performing authentication
java.sql.SQLException: com.microsoft.jdbc.sqlserver.SqlServerDriver
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:589)
at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:344)
at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:229)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:446)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)


Thanks!
 
Mike Aguilar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. I figured it out.

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic