SybSQLException: The datastream for token 236 should only 解决方案

运行以下程序是总是抛出一个异常:
Caused by: com.sybase.jdbc3.jdbc.SybSQLException: The datastream for token 236 should only be sent after other datastreams. It can not be a command datastream on it's own. This is an internal error.

具体方法为:
public List<?> executeProcedure(Class<?> entityClass, String procedure,
String requestId) {
List<?> list = new ArrayList<HibernateProcedureObject>();
try {
session = getCurrentSession(entityClass);
SQLQuery query = session.createSQLQuery(procedure);
query.setString(0, requestId);
list = query.list();
} catch (HibernateException e) {
e.printStackTrace();
logger.log(RMTManagementLevel.ERROR, e);
} finally {
this.closeConnection();
}
return list;
}

异常为:
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2536)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
at com.eagle.utils.hibernatePersistence.HibernateSessionFactory.executeProcedure(HibernateSessionFactory.java:245)
at com.eagle.utils.hibernatePersistence.Test.testAuctionData_Procedure(Test.java:498)
at com.eagle.utils.hibernatePersistence.Test.main(Test.java:512)
Caused by: com.sybase.jdbc3.jdbc.SybSQLException: The datastream for token 236 should only be sent after other datastreams. It can not be a command datastream on it's own. This is an internal error.

at com.sybase.jdbc3.tds.Tds.processEed(Tds.java:2942)
at com.sybase.jdbc3.tds.Tds.nextResult(Tds.java:2246)
at com.sybase.jdbc3.tds.Tds.getResultSetResult(Tds.java:2853)
at com.sybase.jdbc3.tds.TdsCursor.open(TdsCursor.java:295)
at com.sybase.jdbc3.jdbc.SybStatement.executeQuery(SybStatement.java:1659)
at com.sybase.jdbc3.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:97)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
... 9 more

解决方案:
只能利用传统的Connection和ResultSet的形式:
resultSet = null;
try {
cstmt = getCurrentSession(entityClass).connection().prepareCall(
"{call " + procedure + "}");
resultSet = cstmt.executeQuery();
} catch (HibernateException e) {
this.closeConnection();
e.printStackTrace();
logger.log(RMTManagementLevel.ERROR, e);
} catch (SQLException e) {
this.closeConnection();
e.printStackTrace();
logger.log(RMTManagementLevel.ERROR, e);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值