设为首页 加入收藏

TOP

SybSQLException: The datastream for token 236 should only(一)
2014-11-23 22:54:19 来源: 作者: 【 】 浏览:17
Tags: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();
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);
}

作者“来杯咖啡,随便聊聊。”

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇pb9获取文件创建时间、最后修改时.. 下一篇PB9中通过网址(域名)获取IP的方..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: