Search code examples
javastored-proceduresjdbcsybaseresultset

When reading Sybase column from ResultSet I get "JZ006: Caught IOException: java.io.IOException: JZ0R3: Column is DEAD."


I have a Java project and a Sybase database. I am using JDBC to query a stored procedure.

However, when I make a call to read a certain column value of the result set, I get the following error:

Caused by: java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0R3: Column is DEAD.  This is an internal error; please report it to Sybase technical support.
    at com.sybase.jdbc4.jdbc.ErrorMessage.raiseError(ErrorMessage.java:753)
    at com.sybase.jdbc4.jdbc.ErrorMessage.raiseErrorCheckDead(ErrorMessage.java:1166)
    at com.sybase.jdbc4.tds.TdsJdbcInputStream.getString(TdsJdbcInputStream.java:2371)
    at com.sybase.jdbc4.jdbc.SybResultSet.getString(SybResultSet.java:320)

Other columns are working fine.

Here is an example:

var id = rs.getLong("id"); // works fine
var created = rs.getObject("created"); // throws an error

What could I be doing wrong?


Solution

  • The problem was that I haven't read the columns in the correct order.

    The columns have to be read in the order as they are specified in the stored procedure.

    For example, when the stored procedure is:

    create or replace procedure my_procedure()
    as
    begin
        select
               o.id, o.name, o.created
        from order o
    end
    go
    

    Then the columns have to be read in this order:

    var id = rs.getLong("id"); // works fine
    var name = rs.getString("name"); // !!! was missing in the question's example above
    var created = rs.getObject("created"); // works fine now