大家帮帮忙,看看这段程序怎么改?

zzpping 2002-01-24 12:22:27
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>

<%
String username="username";
String password="password";
String nickname="nickname";
String email="email";
String address="address";
String sex="sex";
String age="age";
String comment="comment";
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Java论坛</title>
</head>

<%

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:forum","sa","");

Statement stmtlist=conn.createStatement();
String SQL="SELECT * FROM forumuser where username='"+username+"'"+" and password='"+password+"'";
//out.println(SQL);
boolean boolCanRegister=true;
ResultSet rslist=stmtlist.executeQuery(SQL);
rslist.last();
int lastrow=rslist.getRow();
if(lastrow!=0)
{
boolCanRegister=false;
//out.println("here");
rslist.close();
}
stmtlist.close();
%>

<%
if (boolCanRegister==true)
{
java.sql.Statement stmtPost=conn.createStatement();
//out.println("here");
String strSQL="INSERT INTO forumuser ";
strSQL+="(username,nickname,password,sex,email,age,address,comment,register,postcount,status,usertype,expr)";
strSQL+="values(";
strSQL+="'"+username+"',";
strSQL+="'"+nickname+"',";
strSQL+="'"+password+"',";
strSQL+="'"+sex+"',";
strSQL+="'"+email+"',";
strSQL+="'"+age+"',";
strSQL+="'"+address+"',";
strSQL+="'"+comment+"',";
strSQL+="getdate(),";
strSQL+="0,";
strSQL+="'unknown',";
strSQL+="'normal',";
strSQL+="5";
strSQL+=")";
out.println(strSQL);
stmtPost.executeUpdate(strSQL);
stmtPost.close();
}
%>


运行出错提示为:

Error: 500
Location: /examples/forum1/register1.jsp
Internal Servlet Error:

javax.servlet.ServletException: Result set type is TYPE_FORWARD_ONLY
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:386)
at f_00025rum_00031._0002fforum_00031_0002fregister_00031_0002ejspregister1_jsp_6._jspService(_0002fforum_00031_0002fregister_00031_0002ejspregister1_jsp_6.java:150)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:174)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
at org.apache.tomcat.service.TcpWorkerThread.run(PoolTcpEndpoint.java:366)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:411)
at java.lang.Thread.run(Thread.java:484)


大家帮帮忙,看看怎么改?
...全文
31 点赞 收藏 3
写回复
3 条回复
yanchang 2002年01月24日
Statement stmtlist=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

你的系统必须支持JDBC2.0
否则去生计JDBC
回复 点赞
zzpping 2002年01月24日
在那儿查看自己系统的jdbc版本呢?
回复 点赞
zzpping 2002年01月24日
如果系统不支持JDBC2.0,
上面程序该如何该呢?
回复 点赞
发动态
发帖子
Web 开发
创建于2007-09-28

5.2w+

社区成员

34.1w+

社区内容

Java Web 开发
社区公告
暂无公告