how to handle return values for update sql

Posted on 2006-05-23
Last Modified: 2012-06-27
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:
Question by:eldoz12
    LVL 86

    Expert Comment

    >>my program crashes whenever it receives the row back on the update statement ,

    Please post full exception stack trace + code

    Author Comment

    Below is the code i use for update       

    public void approveFiling(Integer recordId) throws DAOException, ResourceException  {
            String sql="exec spApprove " + recordId;
                      Object[] args = null;
     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 )
              if(maxRows < Integer.MAX_VALUE)

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

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

            return rows;
    LVL 86

    Expert Comment

    You  didn't post the full stack trace
    LVL 92

    Accepted Solution

    Use a CallableStatement to call a sp

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now