Hi,
I am calling a stored procedure to receive data in a results set, I loop through the results set and create hidden fields with the results. The data is coming back correctly and everthing is fine until I run the same servlet again, it doesnt work unless I hit the refresh button, can someone clarify if am closing the DB connections correctly or if there is some other issue, see code below. If I take out the db query and just hardcode the input fields it works every time I run.
CallableStatement cstmt = null; this.getDbManager().closeDbStatement(); try { this.getDbManager().createDbStatement(); cstmt = this.getDbManager().getDbConnection().prepareCall("{call myproc(?,?,?,?,?)}"); cstmt.setDouble(1,Double.parseDouble(this.getRequest().getParameter("xBl"))); cstmt.setDouble(2,Double.parseDouble(this.getRequest().getParameter("yBl"))); cstmt.setDouble(3,Double.parseDouble(this.getRequest().getParameter("xTr"))); cstmt.setDouble(4,Double.parseDouble(this.getRequest().getParameter("yTr"))); cstmt.registerOutParameter(5, OracleTypes.CURSOR); cstmt.execute(); ResultSet rs = (ResultSet) cstmt.getObject(5); String f_num = new String(); int i = 1; String p_num = new String(); int p = 1; while (rs.next()) { f_num = rs.getString("f"); p_num = rs.getString("p"); out.println("\t\t<INPUT TYPE=HIDDEN NAME=\"f_id" + i + "\" VALUE=\"" + f_num + "\">\n"); out.println("\t\t<INPUT TYPE=HIDDEN NAME=\"p_id" + p + "\" VALUE=\"" + p_num + "\">\n"); p++; i++; } rs.close(); cstmt.close(); this.getDbManager().closeDbStatement(); this.getDbManager().closeDbConnection(); } catch (SQLException e) { // TODO Auto-generated catch block exceptionErrorLog(e, this.getClass().getName() + "debug1 " + e.toString()); } finally{ //finally block used to close resources try{ if(cstmt!=null) cstmt.close(); }catch(SQLException se2){ }// nothing we can do } }