开发者

How to configure Tomcat 7 for SQL Server 2008 for use in java servlet programs?

I searched whole internet and on this site but I was unable to get the answer. I am developing an servlet and jsp application. In which I created a form in jsp which will redirect its entered data to a servlet and that servlet will transfer that data to a database class that will insert it in a database. My project managers want me to use SQL Server 2008. I installed tomcat 7 and SQL Server 2008. I set the CLASSPATH to the path of sqljdbc.jar. I had done all the settings as found on a tutorial on net. But I am getting an exception as mentioned below.

I am running Windows 7 Home Premium 64-bit. Please anyone tell me clean and step by step procedure to configure tomcat 7 for sql server 2008 database connectivity. Please its really urgent because I have to submit my project before 5 of next month. Thank you in advance.........

Exception I'm getting......

java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
 Stack Trace:

java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at DatabaseClass.openConnection(DatabaseClass.java:22) at DatabaseClass.(DatabaseClass.java:49) at BankMasterAddServlet.doPost(BankMasterAddServlet.java:10) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa开发者_如何学编程lve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:286) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:272) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1730) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)


I set the CLASSPATH to the path of sqljdbc.jar

I do not believe that Tomcat uses any CLASSPATH environment properties that you have defined.

You can either deploy the jar file in the WEB-INF/lib directory of your webapp or add it to the server's lib directory to have the classes available to all applications.


I found the solution on the MSDN site. I was loading the SQL Server driver using the old notation as com.microsoft.jdbc.sqlserver.SQLServerDriver but in newer versions like in SQL Server 2008 they changed the driver name to com.microsoft.sqlserver.jdbc.SQLServerDriver and now it's working.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜