Topic: JSP连接SQL SERVER出错,不知道错在哪里,请各位帮忙 |
Print this page |
1.JSP连接SQL SERVER出错,不知道错在哪里,请各位帮忙 | Copy to clipboard |
Posted by: henbane Posted on: 2005-03-17 19:01 <%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <html> <body> <% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection conn = DriverManager.getConnection ("jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=hbcj602"); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from namelist"; ResultSet rs=stmt.executeQuery(sql); while(rs.next()) {%> 您的第一个字段内容为:<%=rs.getString(1)%> 您的第二个字段内容为:<%=rs.getString(2)%> <%}%> <%out.print("数据库操作成功,恭喜你");%> <%rs.close(); stmt.close(); conn.close(); %> </body> </html> 出错提示如下: type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SQLServerDriver org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779) org.apache.jsp.connect_jsp._jspService(org.apache.jsp.connect_jsp:94) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver ==》我装了SQL SERVER的JDBC |
2.Re:JSP连接SQL SERVER出错,不知道错在哪里,请各位帮忙 [Re: henbane] | Copy to clipboard |
Posted by: chengbd Posted on: 2005-03-17 20:50 com.microsoft.jdbc.sqlserver.SQLServerDriver 这个类的jar文件应该放在WEB-INF下的lib目录下 |
3.Re:JSP连接SQL SERVER出错,不知道错在哪里,请各位帮忙 [Re: henbane] | Copy to clipboard |
Posted by: henbane Posted on: 2005-03-17 21:42 不好意思,我是新学的。 应该放在哪个目录下的WEB-INF下的lib目录里?直接放好就可以了,还是要 jar -xf mssqlserver.jar 执行一下? 我用的是TOMCAT 5.5 |
4.Re:JSP连接SQL SERVER出错,不知道错在哪里,请各位帮忙 [Re: henbane] | Copy to clipboard |
Posted by: henbane Posted on: 2005-03-18 19:14 我在程序所在目录下面的WEB-INF\lib下也复制了这3个JAR文件啊,可是还是出错啊。有没有人知道啊 |
5.Re:JSP连接SQL SERVER出错,不知道错在哪里,请各位帮忙 [Re: henbane] | Copy to clipboard |
Posted by: henbane Posted on: 2005-03-18 19:27 经过试验,成功了 好象是因为我数据库名DATABASE和数据表名TABLE是一样的关系 我把他们名取不同后就正常了 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |