从数据库获取数据时遇到问题。
我有一个名为purchaseorder
的表,从中我有数量列使用,必须通过用户输入减去一些金额,并通过jsp页面显示结果,帮我解决问题
以下是代码,
String pno = request.getParameter("PONo");
String receivedQty =request.getParameter("ReceivedQty");
int Rqty = Integer.parseInt(receivedQty);
/*String quantity = request.getParameter("Quantity");
int Qty = Integer.parseInt(quantity);*/
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306", "root", "dinga");
PreparedStatement ps = conn.prepareStatement("Select PODate,PONo,Quantity AS OrderingQty ,(Quantity-?) AS BalanceQty From project.purchaseorder where PONo=?");
ps.setInt(1,Rqty );
ps.setString(2,pno );
ResultSet rs = ps.executeQuery();
//System.out.println("resultset Value"+rs);
if (rs.next()) {
request.setAttribute("result", rs);
rd = request.getRequestDispatcher("ProcessingActualGRN.jsp");
rd.forward(request, response);
}
} catch (SQLException e) {
} catch (ClassNotFoundException e) {
} finally {
try {
if (conn != null) {
conn.close();
}
} catch (SQLException ex) {
}
}
}
}
jsp page
<table id="table2">
<tr>
<th>Iteam Discription</th>
<th>OrderingQty</th>
<th>PO Date</th>
<th>Reveived Quantity</th>
<th>Balance Quantity</th>
<th>Received Date</th>
</tr>
<%
do {
%>
<tr>
<td><%=request.getParameter("PONo") %></td>
<td><%=rs.getInt(25)%></td>
<td><%=request.getParameter("Quantity") %>
<!-- <td>null(1)</td> -->
<td><%=rs.getString(1) %></td>
<td><%=request.getParameter("ReceivedQty")%></td>
<td><%=request.getParameter("BalanceQty")%></td>
<td><%=request.getParameter("ReceivedDate")%></td>
</tr>
<%
} while (rs.next());
%>`
在jsp <%=rs.getInt(25)%>
中我收到错误
org.apache.jasper.JasperException:在第87行处理JSP页面/ProcessingActualGRN.jsp时发生异常
87:&lt;%= rs.getInt(25)%&gt;
答案 0 :(得分:0)
EF