日期:2014-05-18  浏览次数:20664 次

不知道是什么错误
我用的

<%@   page   contentType= "text/html;charset=gb2312 "%>  

<%@   page   import= "java.sql.* "%>  

<html>  

<body>  

<%
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();  


String   url= "jdbc:microsoft:sqlserver://EVON1020V:1433;DatabaseName=sqldata ";  


//pubs为你的数据库的  

String   user= "sa ";  

String   password= "520 ";  
Connection   conn=   DriverManager.getConnection(url,user,password);  

Statement   stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  


String   sql= "select   *   from   userat ";  

ResultSet   rs=stmt.executeQuery(sql);  

while(rs.next())   {%>  

您的第一个字段内容为: <%=rs.getString(1)%>  

您的第二个字段内容为: <%=rs.getString(2)%>  

<%}%>  

<%out.print( "数据库操作成功,恭喜你 ");%>  

<%rs.close();  

stmt.close();  

conn.close();  
%>  

</body>  

</html>
------------------------
用的是
jdk1.5.0_04
eclipse3.2
Apache   Tomcat   5.0


出错以下错误


HTTP   Status   500   -  

--------------------------------------------

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:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.myjsp_jsp._jspService(myjsp_jsp.java:105)
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.SQLServerDriver
org.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:148)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:69)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
java.lang.Class.forName0(Native   Method)
java.lang.Class.f