读书人

不知道是什么东东

发布时间: 2013-09-11 17:59:58 作者: rapoo

不知道是什么错误
我用的

<%@ 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.forName(Class.java:164)
org.apache.jsp.myjsp_jsp._jspService(myjsp_jsp.java:52)
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.28 logs.


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

Apache Tomcat/5.0.28

[解决办法]
没有设置数据库驱动。把mssqlserver的驱动3个jar包放到tomcat下的common/lib下
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

读书人网 >Java Web开发

热点推荐