WAS : DSRA9110E: Statement is closed

问题描述

在重复提交或多客户操作时老出现DSRA9110E:Statementisclosed这个错误,大大们帮忙看下行不。谢谢了!下面是我调用的方法,入口为selRefForProNo,error是在执行select()方法是出现的:publicclassReservationExecControllerextendsReservationBaseController{publicReservationExecController(ActionMappingmapping,HttpServletRequestrequest,HttpServletResponseresponse,ConnectionManagerconnMgr,ActionMessageManagermessageMgr){super(mapping,request,response,connMgr,messageMgr);//TODO自动生成的构造函数存根}publicList<ReservationNodepad>selReservationNodepad(ReservationNodepadreservationNodepad)throwsException{ReservationExecManagerreservationExecManager=newReservationExecManager(connMgr,messageMgr);returnreservationExecManager.select(reservationNodepad);}publicList<GenericCode>selGenericCode(GenericCodegenericCode)throwsException{ReservationExecManagerreservationExecManager=newReservationExecManager(connMgr,messageMgr);returnreservationExecManager.select(genericCode);}publicList<ReservationSchedule>selReservationSchedule(ReservationSchedulereservationSchedule)throwsException{ReservationExecManagerreservationExecManager=newReservationExecManager(connMgr,messageMgr);reservationSchedule.setActiveIdx(ReservationParameter.ACTIVEIDX_Y);returnreservationExecManager.select(reservationSchedule);}publicList<Proposal>selProposal(Proposalproposal)throwsException{ReservationExecManagerreservationExecManager=newReservationExecManager(connMgr,messageMgr);returnreservationExecManager.select(proposal);}publicList<ReservationTransaction>selReservationTransaction(ReservationTransactionreservationTransaction)throwsException{ReservationExecManagerreservationExecManager=newReservationExecManager(connMgr,messageMgr);returnreservationExecManager.select(reservationTransaction);}publicList<ReservationStatus>selReservationStatus(ReservationStatusreservationStatus)throwsException{ReservationExecManagerreservationExecManager=newReservationExecManager(connMgr,messageMgr);returnreservationExecManager.select(reservationStatus);}publicbooleanselRefForProNo(ReservationExecFormreservationExecForm)throwsException{booleanbool=true;List<Proposal>proList=selProposal(reservationExecForm.getProposal());bool=isValiProNo(proList);bool=bool&&ReservationParameter.LOAN_STATUS_SIGN.equals(proList.get(0).getStatus());if(bool){reservationExecForm.setProposal(proList.get(0));selReservationExecForm(reservationExecForm);ReservationLockingreservationLocking=newReservationLocking();reservationLocking.setProposalNo(reservationExecForm.getProposal().getProposalNo());List<ReservationLocking>rlList=selReservationLock(reservationLocking);if(rlList.size()>0&&!request.getSession().getAttribute("username").toString().equals(rlList.get(0).getCreateBy())){reservationExecForm.setIsLock(true);reservationExecForm.setReservationLocking(rlList.get(0));}else{bool=bool&&addReservationLocking(reservationLocking)==1?true:false;reservationExecForm.setIsLock(false);reservationExecForm.setReservationLocking(reservationLocking);}getReservationExecList(reservationExecForm);}returnbool;}publicbooleanselReservationExecForm(ReservationExecFormreservationExecForm)throwsException{booleanbool=true;ReservationNodepadreservationNodepad=newReservationNodepad();reservationNodepad.setProposalNo(reservationExecForm.getProposal().getProposalNo());Util.clearList(reservationExecForm.getRnList()).addAll(selReservationNodepad(reservationNodepad));for(ReservationNodepadrn:reservationExecForm.getRnList()){if(rn.getCreatedDate()!=null){rn.getRnd().setCreatedDate(Util.DateStringConverter(rn.getCreatedDate(),ReservationParameter.DATE_FORMAT_ITEM));}if(rn.getLastUpdatedDate()!=null){rn.getRnd().setLastUpdatedDate(Util.DateStringConverter(rn.getLastUpdatedDate(),ReservationParameter.DATE_FORMAT_ITEM));}}ReservationSchedulereservationSchedule=newReservationSchedule();reservationSchedule.setBranchCode(reservationExecForm.getProposal().getBranchCode());Util.clearList(reservationExecForm.getRsList()).addAll(selReservationSchedule(reservationSchedule));GenericCodegenericCode=newGenericCode();genericCode.setCategory(ReservationParameter.CATEGORY);List<GenericCode>gcList=selGenericCode(genericCode);for(GenericCodegc:gcList){if(gc.getGroupCode()==null||"".equals(gc.getGroupCode())){reservationExecForm.getGcParentList().add(gc);}else{reservationExecForm.getGcChildList().add(gc);}}reservationExecForm.getReservationStatus().setActiveIdx(ReservationParameter.ACTIVEIDX_Y);reservationExecForm.getReservationStatus().setProposalNo(reservationExecForm.getProposal().getProposalNo());List<ReservationStatus>rsList=selReservationStatus(reservationExecForm.getReservationStatus());reservationExecForm.setReservationStatus(rsList.size()==1?rsList.get(0):null);reservationExecForm.getReservationTransaction().setActiveIdx(ReservationParameter.ACTIVEIDX_Y);reservationExecForm.getReservationTransaction().setProposalNo(reservationExecForm.getProposal().getProposalNo());List<ReservationTransaction>rtList=selReservationTransaction(reservationExecForm.getReservationTransaction());reservationExecForm.setReservationTransaction(rtList.size()==1?rtList.get(0):null);if(rtList.size()>0){DatereserveDate=reservationExecForm.getReservationTransaction().getReserveDate();reservationExecForm.setReserveDate(reserveDate==null?null:Util.DateStringConverter(reserveDate,ReservationParameter.DATE_FORMAT_NOITEM));}else{reservationExecForm.setReserveDate(null);}Collections.sort(reservationExecForm.getRsList());returnbool;}

解决方案

解决方案二:
publicclassBaseManager{publicConnectionManagerconnMgr=null;publicstaticLoggerlogger=Parameter.logger;protectedActionMessageManagermessageMgr=null;public<TextendsObject>List<T>select(Tentity)throwsException{List<T>list=newArrayList<T>();Classcls=entity.getClass();StringtblName=Util.getOracleName(cls.getSimpleName());Connectionconn=null;PreparedStatementps=null;ResultSetrs=null;StringBuffersql=newStringBuffer("Select");StringBuffersql1=newStringBuffer();List<Object>valueList=newArrayList<Object>();Field[]fields=cls.getDeclaredFields();for(Fieldfield:fields){StringproName=field.getName();if(Util.DATA_TYPE_MAP.containsKey(field.getType().getName())){if(Parameter.DATA_STATUS.equals(field.getType().getName())){sql.append("to_char(").append(Util.getOracleName(proName));sql.append(",'yyyy-mm-ddhh24:mi:ss')").append(Util.getOracleName(proName));sql.append(",");}else{sql.append(Util.getOracleName(proName)).append(",");}}Objectvalue=Util.getProValue(entity,field);if(Util.DATA_TYPE_MAP.containsKey(field.getType().getName())&&value!=null&&!"".equals(value)){if(!field.getType().getName().equals(field.getType().getSimpleName())){if(Parameter.DATA_STATUS.equals(field.getType().getName())){sql1.append("and").append("to_char(").append(Util.getOracleName(proName));sql1.append(",'yyyy-mm-dd')").append("=?");value=Util.DateStringConverter((Date)value,"yyyy-MM-dd");}else{sql1.append("and").append(Util.getOracleName(proName)).append("=?");}valueList.add(value);}}}sql=sql.delete(sql.length()-1,sql.length());sql.append("from").append(tblName).append("where1=1");sql.append(sql1);try{conn=connMgr.getConnection();ps=conn.prepareStatement(sql.toString());for(inti=0;i<valueList.size();i++){ps.setObject(i+1,valueList.get(i));}rs=ps.executeQuery();while(rs.next()){ObjectentityObj=Class.forName(cls.getName()).newInstance();for(Fieldfield:fields){if(Util.DATA_TYPE_MAP.containsKey(field.getType().getName())){Objectvalue=rs.getObject(Util.getOracleName(field.getName()));if(Parameter.DATA_STATUS.equals(field.getType().getName())&&value!=null){value=Util.DateStringConverter(value.toString(),"yyyy-MM-ddHH:mm:ss");}Util.setProValue(entityObj,field,value);}}list.add((T)entityObj);}}catch(Exceptione){e.printStackTrace();logger.error("selectSqlexception(table"+tblName+"):"+e);throwe;}finally{try{if(rs!=null||!rs.isClosed()){rs.close();rs=null;}if(ps!=null||!ps.isClosed()){ps.close();ps=null;}}catch(SQLExceptione){e.printStackTrace();}}returnlist;}}
解决方案三:
BaseManager类是ReservationExecManager类的父类,在调试时发现某些时候执行BaseManager类中select()的rs=ps.executeQuery()时就会出现DSRA9110E:Statementisclosed,我一开始以为是多线程的问题,在select(),selRefForProNo()方法前加了synchronized,但是没有效果。大大们帮忙看看咯,我研究一天了都。谢谢!!!
解决方案四:
该回复于2011-02-18 09:23:26被版主删除
解决方案五:
大大们帮忙看看啊,谢谢!
解决方案六:
搜了一下,网上说是连接池问题。你试过直连数据库没有?
解决方案七:
try{if(rs!=null||!rs.isClosed()){rs.close();rs=null;}if(ps!=null||!ps.isClosed()){ps.close();ps=null;}}catch(SQLExceptione){e.printStackTrace();}

楼主,不要一遇到try就close,先要看还有用没。希望对你有帮助
解决方案八:
引用6楼woshigaoshou980的回复:

Javacodetry{if(rs!=null||!rs.isClosed()){rs.close();rs=null;}if(ps!=null||!ps.isClosed()){ps.close();ps=null;}}catch(SQLExceptione){e.printStackTrace();}楼主……

我是把结果集写入list后,在finally块中关闭的rs和ps,不是很明白你所说的还有用没的意思
解决方案九:
ResultSet和PreparedStatement会自动失效吗?
解决方案十:
怎么没人回呢?自己顶下!

时间: 2024-12-22 17:47:25

WAS : DSRA9110E: Statement is closed的相关文章

SQLExecption:Operation not allowed after ResultSet closed解决办法

原网址:http://blog.csdn.net/sku0923/article/details/1722370 一个stmt多个rs进行操作引起的ResultSet已经关闭错误 一个stmt多个rs进行操作. 那么从stmt得到的rs1,必须马上操作此rs1后,才能去得到另外的rs2,再对rs2操作. 不能互相交替使用,会引起rs已经关闭错误. 错误的代码如下:  stmt=conn.createStatement();   rs=stmt.executeQuery("select * fro

关于java.sql.SQLRecoverableException: Closed Connection异常的解决方案(转)

在项目中碰到了一个应用异常,从表象来看应用僵死.查看Weblogic状态为Running,内存无溢出,但是出现多次线程堵塞.查看Weblogic日志,发现程序出现多次Time Out. 我们知道,Weblogic会自动检测线程运行超时,当超过特点时间(默认600S),即认为此线程为堵塞线程.在日志中发现多次堵塞线程,通过查找资料,发现Weblogic在发生多次线程堵塞后,会自动把应用挂起.默认次数为15次.   是什么造成了线程堵塞呢?通过进一步分析日志,我们发现在线程堵塞之前,发生了多次jav

psycopg2 postgresql driver for python don&#039;t support prepared statement Direct

前面使用py-postgresql测试过PostgreSQL性能, 可能是这个驱动效率较低, 我们接下来使用psycopg2测试一下. psycopg2使用libpq接口, 支持2PC, 支持异步提交等, 但是不支持绑定变量. 安装 [root@localhost ~]# . /home/postgres/.bash_profile root@localhost-> which pg_config /opt/pgsql9.3.5/bin/pg_config [root@localhost ~]#

websphere 连接池总是报statement、connect is close ,怎么解决?

问题描述 com.ibm.websphere.ce.cm.ObjectClosedException:DSRA9110E:关闭Statement.我的应用总有这个问题,上网查说websphere连接池在JNDI初始化一个连接时会出现这种情况,请问我该怎么做去避免呢? 解决方案 解决方案二:同问解决方案三:请大虾们踊跃发言,别沉了解决方案四:不会是循环中执行sql语句吧,要不Statement为单例模式?解决方案五:我认为很可能是Statement创建没释放,Connect也没正常关闭造成连接池中

Object has been closed.

问题描述 Connection conn= DbUtil.getConnection();Statement stmt=null;System.out.println(conn+"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

SQLException: ResultSet is closed

问题描述 ResultSet zwrs2 = statement.executeQuery(sql);while(zwrs2.next()){ outputDate(zwrs2);}public void outputDate(ResultSet zwrs2){ ResultSet dbrs = statement.executeQuery(sql); while(dbrs.next()){ double value = zwrs2.getDouble(db_col);//字段名,当执行到其中一

JDBCTM 指南:入门4 - Statement

4 - Statement 本概述是从<JDBCTM Database Access from JavaTM: A Tutorial and Annotated Reference >这本书中摘引来的.JavaSoft 目前正在准备这本书.这是一本教程,同时也是 JDBC 的重要参考手册,它将作为 Java 系列的组成部份在 1997 年春季由 Addison-Wesley 出版公司出版. 4.1 概述 Statement 对象用于将 SQL 语句发送到数据库中.实际上有三种 Statemen

报错:Socket connection closed by the other side (how rude!)

最近,公司邮箱发送到另一家公司的时总会退信:Socket connection closed by the other side (how rude!).[插:安装MDaemon的版本是最新的12.x版本,降级成10.x的版本就可以正常收发].退信在用户的邮箱里,没传过来.查了一下smtp出的日志,具体截图如下: 从日志分析来看,我方服务器开启了tsl.想到这里,查看一下mdaemon的ssl设置情况,结果发现12版本默认 勾选 SMTP服务器尽可能使用STARTTLS的.取消勾选 SMTP服务

JDBC中Statement,PreparedStatement,CallableStatement三个方法的实例

public void ListStudents() throws SQLException{ int i, NoofColumns; String StNo, StFName, StLName; //初始化并加载JDBC-ODBC驱动程序 Class.forName("jdbc.odbc.JdbcOdbcDriver"); //创建连接对象 Connection Ex1Con = DriverManager.getConnection("jdbc:odbc:StudentD