<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ page import="page.*" %>
<%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'view.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<jsp:useBean id="trace" scope="session" class="page.Trace"></jsp:useBean>
<jsp:useBean id="myconn" scope="request" class="DataBase.connectData"></jsp:useBean>
<body>
<%
request.setCharacterEncoding("gb2312");
Content content=Content.getContent();
String user_id=request.getParameter("user");
trace.setName(user_id);
content.addElement(trace.getName());
session.setMaxInactiveInterval(5);
%>
<%
int i=0;
//Vector vector=content.getElements();
//for(i=0;i<vector.size();i++){
// Trace ta=(Trace) vector.elementAt(i);
// out.print(ta.getName());
// }
int count=0;
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
conn=myconn.getconn();
try{
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from stuBaseInfo";
rs=stmt.executeQuery(sql);
rs.last();
count=rs.getRow();
rs.beforeFirst();
Enumeration elements=content.getElements();
while(elements.hasMoreElements())
{
String id=(String)elements.nextElement();
for(i=0;i<count;i++)
{ rs.next();
if (rs.getString(1).equals(id)){
rs.absolute(i);
rs.updateString("stuas","on");
rs.updateRow();
}
//out.print(id);
out.print(rs.getString(1));
out.print(rs.getString(2));
out.print(rs.getString(3));
out.print(rs.getString(4));
out.print(rs.getString(5) + "<br>");
//out.print(id);
}
rs.beforeFirst();
}
}
catch(Exception e){
//out.print("错误"+e);
}
%>
</body>
</html>
上面那段代码,能显示出数据库的记录,但是不能修改,
if (rs.getString(1).equals(id)){
rs.absolute(i);
rs.updateString("stuas","on");
rs.updateRow();
这个没用,其他的那些类都有用,我只想实现下功能,
上面那个user是从另个页面传递过来的,是数据库的第一条记录;
哪为大虾能帮帮指出下问题,谢谢!
[此贴子已经被作者于2007-10-18 10:55:01编辑过]