求助:一个jsp访问sql 2000数据库的问题,谢谢,在线等。
求助:一个jsp访问sql 2000数据库的问题,谢谢 代码如下:
<%@ page import= "java.lang.*,java.io.*,java.sql.*,java.util.* " contentType= "text/html;charset=gb2312 "%>
<html>
<body>
<%Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test "; //test 为你的数据库的
Connection conn= DriverManager.getConnection(url, " ", " ");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql= "select username,old from test1 ";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
%>
您的第一个字段内容为: <%=rs.getString(1)
%>
<br>
您的第二个字段内容为: <%=rs.getString(2)
%>
<br>
<%
}
%>
<%
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
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 4 in the jsp file: /sql_test.jsp
Generated servlet error:
Syntax error on token "Invalid Character ", delete this token
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 4 in the jsp file: /sql_test.jsp
Generated servlet error:
Syntax error on token "Invalid Character ", delete this token
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:329)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.2 logs.
[解决办法]
给SQL打补丁
[解决办法]
sql 2000 sp4补丁
jdbc里面的确3个jar文件要拷贝到tomcate里面
[解决办法]
用jdbc驱动至少是sp3吧,没装补丁不行
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html