Microsoft JDBC "ResultSet Can Not Re-Read Row Data" Error解决办法

http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=123&threadID=27318&tstart=0
先k一下M$
使用MS SQL Server 2000 SP3a做数据库服务器时,用Microsoft提供的JDBC驱动(2.2.0040),在查询时遇到一个SQLException:java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column #.
查询语句和JDBC代码都没有问题,怀疑是Microsoft驱动的BUG,google一下果然在Microsoft support站点发现了问题:http://support.microsoft.com/kb/824106
原因是如果该表存在TEXT, NTEXT, IMAGE等大型字段,对于ResultSet的字段读取必须按照从左向右读,如果你用:
int a = rs.getInt(2);
int b = rs.getInt(1);
则报错。
Microsoft给出的方案是不能从右往左也不能连续读2次。没办法自己改代码,严格从左向右读,结果就没有问题了。

后来用sql server 2000 sp4 + ms jdbc driver sp3测试依然有这个BUG估计Microsoft故意不肯解决这种BUG。
阅读更多

ResultSet can not re-read row data for column 2是怎么回事啊

08-10

我的页面是:rn<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>rn<%@ page import="java.io.*"%>rnrnrn<%request.setCharacterEncoding("gb2312");%>rnrnrnrn title>rn rnrnrnrn<%!rn Connection conn1;rn Connection conn2;rn Statement stmt1,stmt2;rn ResultSet rs1,rs2;rn rn%>rn<%rnString sql1="select * from hangong_info where identification='"+request.getParameter("id")+"'";rnString sql2="select * from kaoShi where identification='"+request.getParameter("id")+"' and testDate='"+request.getParameter("testDate")+"'";rntryrnrn conn1=DBConn.getConnection();rn conn2=DBConn.getConnection();rn stmt1=conn1.createStatement();rn stmt2=conn2.createStatement();rn rs1=stmt1.executeQuery(sql1);rn rs2=stmt2.executeQuery(sql2);rn if(!rs1.next()||!rs2.next())rn out.print("数据库中没有相应的记录!");rnrncatch(Exception e)rnrnout.print("数据库连接不成功--------"+e.getMessage());rnrn%>rnrn rn rn 姓名rn ">rn 身份证号rn ">rn 性别rn ">rn rn rn 出生年月rn ">rn 工种rn ">rn 现有文化程度rn ">rn rn rn rn 从事焊接连续工龄rn ">rn 工作单位rn ">rn 部门rn ">rn rn rn 单位地址rn ">rn 现有合格类别rn ">rn 申请考试类别rn ">rn rn rn 考试日期rn ">rn 考试科目rn ">rn 考试地点rn ">rn rn rn 焊接材料rn ">rn 试件材料rn ">rn 钢印编号rn ">rn rn rn 外观检查rn ">rn 弯曲试验rn ">rn 宏观检查rn ">rn rn rn 基本知识rn ">rn 备注rn ">rn rn rn rn <%rn //查询出考试录和照片的地址,转化成相应的地址.rn String record=rs2.getString("testOnlineRecordName");rn String photo=rs1.getString("photoName");rn record="../hangong/testOnlineRecord/"+record;rn photo="../hangong/photo/"+photo;rn %>rn rn 现场考试记录rn rn 从事焊接工作简历rn ">rn 照片rn rn rnrnrnrn--------------------------------------------------------------------------rn错误信息:rn--------------------------------------------------------------------------rnjavax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 2.rn org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)rn org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)rn org.apache.jsp.hangongInfo_jsp._jspService(hangongInfo_jsp.java:148)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:856)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:856)rn filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:38)rnrnrnroot cause rnrnjava.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 2.rn com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)rn com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)rn com.microsoft.jdbc.base.BaseResultSet.validateColumnIndex(Unknown Source)rn com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)rn com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)rn org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:216)rn org.apache.jsp.hangongInfo_jsp._jspService(hangongInfo_jsp.java:85)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:856)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:856)rn filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:38)rnrnrnnote The full stack trace of the root cause is available in the Tomcat logs.rnrnrnrnrn

[SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 3

01-13

严重: Servlet.service() for servlet jsp threw exceptionrnjava.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 3.rn at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)rn at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)rn at com.microsoft.jdbc.base.BaseResultSet.validateColumnIndex(Unknown Source)rn at com.microsoft.jdbc.base.BaseResultSet.getInt(Unknown Source)rn at com.microsoft.jdbc.base.BaseResultSet.getInt(Unknown Source)rn at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:237)rn at org.hibernate.type.IntegerType.get(IntegerType.java:28)rn at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)rn at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)rn at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1097)rn at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:565)rn at org.hibernate.loader.Loader.doQuery(Loader.java:701)rn at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)rn at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)rn at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)rn at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)rn at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)rn at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)rn at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)rn at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)rn at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:249)rn at org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(ForEachSupport.java:348)rn at org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(ForEachSupport.java:224)rn at org.apache.taglibs.standard.tag.common.core.ForEachSupport.prepare(ForEachSupport.java:155)rn at javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(LoopTagSupport.java:256)rn at org.apache.jsp.form.category.listCategory_jsp._jspx_meth_c_005fforEach_005f1(listCategory_jsp.java:221)rn at org.apache.jsp.form.category.listCategory_jsp._jspx_meth_c_005fforEach_005f0(listCategory_jsp.java:159)rn at org.apache.jsp.form.category.listCategory_jsp._jspService(listCategory_jsp.java:73)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)rn at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)rn at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)rn at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)rn at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)rn at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)rn at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)rn at java.lang.Thread.run(Thread.java:619)rn2014-1-13 12:44:31 org.apache.catalina.core.StandardWrapperValve invokernrnrn

没有更多推荐了,返回首页