关于jsp连接sql server 2000的问题,baidu了很多资料,但是还是不行啊!
日期:2006-10-14 荐:
关于jsp连接sql server 2000的问题,baidu了很多资料,但是还是不行啊!我已经安装jdbc for sql server 2000,三个jar已经拷贝到Java\jre\lib\ext和Tomcat 5.0/common/lib下,classpath=C:\Program Files\Java\bin;.;C:\Program Files\Java\lib;C:\Program Files\Java\lib\dt.jar;C:\Program Files\Java\lib\tools.jar;D:\Tomcat 5.0\common\lib\servlet-api.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar有JAVA_HOME和TOMCAT_HOME.测试的主要代码如下String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; String connURL = "jdbc:microsoft:sqlserver://FLYING:1433;User=sa;Password=hcazpd;DatabaseName=se"; try{ Class.forName(driverName); Connection con = DriverManager.getConnection(connURL); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from [user]");这一段代码,我写成.java文件,编译执行是没有问题的.但我放到jsp文件里面后,就会发生如下错误:HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SqlServerDriverorg.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)org.apache.jsp.test_jsp._jspService(test_jsp.java:127)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root cause java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SqlServerDriverorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:150)org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:71)java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)java.lang.Class.forName0(Native Method)java.lang.Class.forName(Class.java:141)org.apache.jsp.test_jsp._jspService(test_jsp.java:81)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.--------------------------------------------------------------------------------Apache Tomcat/5.0.30请大家指教没有人知道吗?String connURL = "jdbc:microsoft:sqlserver://FLYING:1433;DatabaseName=se"; try{ Class.forName(driverName); Connection con = DriverManager.getConnection(connURL,User,Password); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from [user]");在你的工程里面加载这三个文件。。。。从错误提示来看,还是没有找到驱动程序。在Eclipse中将这三个jar包加入Java Build Path 或者项目的 Build Path就行了吧。pxjianke(一无所有-光明唧) 叫了try后还是老样子xu_xinyu(雪候鸟这个找不到驱动我也知道,那究竟怎么 样才可以找到驱动呢?在Eclipse中将这三个jar包加入Java Build Path 或者项目的 Build Path就行了吧。Java Build Path 里面已经又这三个jar了.但还是不行呢!而且,我觉得,在Eclipse有没有包含这个包是没有什么影响的,因为jsp文件通过浏览器浏览的时候,jsp是通过web服务器编译执行的,和Eclipse没有关系的.现在的问题就是Tomcat找不到Sql server的驱动,这个该如何做呢你的sqlserver是装在什么os下的?jdbc for sql server 2000在win2003下面是有问题的你可以选择安装OS的服务器版本的不然会出现问题的我是xp的!在问一个问题sql server 2000的布丁会不会造成这个问题的?我打的是sp1高人快来帮帮我啊版主,高人快出手啊!
标签: