i是從不同頁面捕獲的參數。我將i的值看作1,它應該顯示第n行的表格,但它不顯示任何內容。從數據庫中找到第n行
int i=Integer.parseInt(req.getParameter("index"));
i=i-1;
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","SYSTEM","SYSTEM");
String query="select * from employee1 limit 1 offset i";
PreparedStatement pst=con.prepareStatement(query);
ResultSet rs = pst.executeQuery();
String name = rs.getString(2);
int salary = rs.getInt(3);
PrintWriter out=res.getWriter();
res.setContentType("text/html");
out.println("<form action='update' method=''>");
out.println("Name:<input type='text' name='name' value="+name+"/>");
out.println("Salary:<input type='text' name='salary' value="+salary+ "/>");
out.println("<input type='submit' name='update' />");
out.println("</form>");