Two Laptop Bag*
The moose likes JDBC and the fly likes Cannot create JDBC driver of class SQLServerDriver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Cannot create JDBC driver of class SQLServerDriver" Watch "Cannot create JDBC driver of class SQLServerDriver" New topic
Author

Cannot create JDBC driver of class SQLServerDriver

S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi,
I have tried posting this problem in both the IDE Forum and this forum since The past one week and i haven't got any response.But i'm trying it one more time and i hope somebody helps me out.
The problem is that i am using NetBeans 5.0 version and i'm trying to create a connection pool using Microsoft SQL Server 2000.
I have added the three jar files i.e msutil.jar , mssqlserver.jar and msbase.jar to the netbeans-5.0\enterprise2\jakarta-tomcat-5.5.9\common\lib
then using the netbeans interface, i have created a jdbc pool with the
DataSource classname as: com.microsoft.jdbc.sqlserver.SQLServerDriver
url is : "jdbc:microsoft:sqlserver//localhost:1433;DatabaseName=Test"

the context.xml is this :


Now when i run the application... it throws this error :



I really can't understand what has to be done and i really need someone to help me out of this. Is it just the driver?

Thanks,
Bitz

[changed subject from help]
[ July 26, 2006: Message edited by: Jeanne Boyarsky ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

'Help!!!' isn't a useful topic.

Try taking the jars you listed out of the common/lib directory and putting them in the server/lib directory instead.

The 'common' directory makes the code available to all web applications, but your intent is to create a DB pool managed by the server. Therefore it needs to be available to the server.

Dave
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi Dave!!
I know its not a good topic, but i could not think of a better topic!!
Anyways, i removed the jar files from the common/lib and put it in the server/lib and now i get this error:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at checkServlet.processRequest(checkServlet.java:48)
at checkServlet.doGet(checkServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:760)
... 22 more

Thanks,
Bitz
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

So it still looks like a loading issue, but after going back to read the instructions it looks like your initial setup was correct, the jars should go in the common/lib directory. I'll have a closer look Make sure you don't have any of the jars in your JAVA/jre/lib/ext directory
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Nope, check your database url. I think you need to add an extra colon before the '//'
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Originally posted by S bitz:
Hi Dave!!
I know its not a good topic, but i could not think of a better topic!!

I changed the name of the topic so you get more responses. To come up with a more descriptive subject, try to pick some words that described the problem.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi,
Thanks a lot Dave. That ":" exactly was the problem. I feel so silly, but thanks a lot again.

Moral of the story : "Every problem has a solution and most of the times its as simple as adding a colon!! " ;)

Thanks Jeanne for changing the name.I got the solution


Thanks,
Bitz.
Giri Nag
Greenhorn

Joined: Oct 31, 2006
Posts: 1
I am facing a similar issue. can you please correct me.

<Context path="/test" docBase="C:/home/dev/test/" debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="UserInfo_log." suffix=".txt"
timestamp="true" />

<Resource name="jdbc/test" auth="Container"
type="javax.sql.DataSource"
username="user" password="pwd!"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
maxActive="8" maxIdle="4"
url="jdbc:microsoft:sqlserver://host:port;DatabaseName=dbname" />
</Context>

sqljdbc.jar is palced in the common/lib directory. i have placed the context.xml in the webapp META-INF directory. resource is added in the web.xml
<resource-ref>
<description>DS Connection1</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

tomcat version 5.5

the error is

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at com.hp.utility.DBConnection.showTables(DBConnection.java:55)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:760)

Highly appreciate your help. thank you very much in advance.

-Girish


[ October 31, 2006: Message edited by: Giri Nag ]
[ October 31, 2006: Message edited by: Giri Nag ]
 
 
subject: Cannot create JDBC driver of class SQLServerDriver