[英]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.我有一个 Java 项目和一个 Sybase 数据库。 I am using JDBC to query a stored procedure.我正在使用 JDBC 来查询存储过程。
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?我可能做错了什么?
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.