servlet 只能访问字段一次?(100)

C

cgErp

Unregistered / Unconfirmed
GUEST, unregistred user!
测试代码 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:eek:dbc:myServer","sa","");
Statement statement=con.createStatement();
ResultSet rset=statement.executeQuery("select * from employ");
pw.write("<table width=/"80%/" border=/"1/"> <tr><td>学号</td><td>姓名</td></tr>");
while(rset.next()) { pw.write("<tr><td>"+rset.getString("employid")+"</td>"+"<td>"+rset.getString("employid")+"</td></tr>");
} pw.write("</table></body></html>");
statement.close();
con.close();其中pw.write("<tr><td>"+rset.getString("employid")+"</td>"+"<td>"+rset.getString("employid")+"</td></tr>");两次访问rset.getString("employid")就出错,pw.write("<tr><td>"+rset.getString("employid")+"</td>"+"<td>"+rset.getString("employname")+"</td></tr>") 就不会出错
 
Top Bottom