• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3495
  • Last Modified:

how to handle return values for update sql

Hello experts ,
I call sp which updates a some tables , they return a single row with value 0 if the update is successful ,
The problem is that my program crashes whenever it receives the row back on the update statement ,

Plz advice on how to handel return values on update statments

error log
java.sql.SQLException: JZ0P1: Unexpected result type. Query:
0
eldoz12
Asked:
eldoz12
  • 2
1 Solution
 
CEHJCommented:
>>my program crashes whenever it receives the row back on the update statement ,

Please post full exception stack trace + code
0
 
eldoz12Author Commented:
Below is the code i use for update       


public void approveFiling(Integer recordId) throws DAOException, ResourceException  {
            this.setIgnoreWarnings(true);
        String sql="exec spApprove " + recordId;
                  Object[] args = null;
                   this.updateThrowsDAOException(conn,sql,args);      
      }
 public int updateThrowsDAOException(Connection conn, String sql, Object[] params)
        throws DAOException, ResourceException {

        PreparedStatement stmt = null;
        int rows = 0;

        try {
            stmt = this.prepareStatement(conn, sql);
            this.fillStatement(stmt, params);
          if(timeoutInSec < Integer.MAX_VALUE )
                  stmt.setQueryTimeout(timeoutInSec);
          if(maxRows < Integer.MAX_VALUE)
                  stmt.setFetchSize(maxRows);

            rows = stmt.executeUpdate();
          SQLWarning warn = stmt.getWarnings();
          throwExceptionOnWarningIfNotIgnoringWarnings(warn);

        } catch (SQLException e) {
            this.createDAOException(e, sql, params);
        } finally {
            close(stmt);
        }

        return rows;
    }
0
 
CEHJCommented:
You  didn't post the full stack trace
0
 
objectsCommented:
Use a CallableStatement to call a sp

http://javaalmanac.com/egs/java.sql/CallProcedure.html
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now