Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

pstmt.executeUpdate() return 0

HjavaJul 31 2013 — edited Oct 15 2014

I have function

final public int updateSQL(Connection conn, String preparedSQL, String [] preparedValues){
    int result=-1;
    PreparedStatement pstmt=null;
    try{
        if (preparedValues!=null){
          pstmt = conn.prepareStatement(preparedSQL);
          for (int i=0; i<preparedValues.length; i++){
            setString(pstmt,i+1,preparedValues[i]);
          }
          result = pstmt.executeUpdate();
        }
        else {
          pstmt = conn.prepareStatement(preparedSQL);
          result = pstmt.executeUpdate();
        }
    }
    catch (SQLException e){debugLibrary.p("String directSQL error"+e+preparedSQL+"***");}
    finally{
      try{
          if (pstmt!=null){
            pstmt.close();
            pstmt = null;
          }
        } catch (SQLException sqle){ }
    }
    return result;
  }

[code]

<<<<<<<

for (int i = 0; i<library.getStringValuesLength(req, "stuid"); i++) {

                    

                        String tempDate = req.getParameterValues("stuid")[i]

                    

      

                        String[] updatei = {tempDate};                

                    

                   

                    

                       result= library.updateSQL(conn, Sql2, updatei);

                   

                      

                }

I try to update one or a few rows, it work , I just do get why the successful update, it can return 1 or 0[code]

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 30 2013
Added on Jul 31 2013
4 comments
2,303 views