论坛首页 入门技术论坛

JDBC错误:关闭的语句.

浏览 2492 次
该帖已经被评为新手帖
作者 正文
   发表时间:2008-05-19  
public class CompareFundDAO extends BaseHibernateDAO {
	private static final Log log = LogFactory.getLog(TbSourceDAO.class);
	
	@SuppressWarnings("unchecked")
	public List<CompareFund> getCompareResult(String month){
		try{
                  String where = "qymc not like '%测试%' and qymc not like '%hxtest%' and qymc not like '%zjca%' and qymc not like '%浙江ca%' and dqzt = '新领' and status > 0 and";

String hql1 = "select count(*)*500 from TbHx where "+where+" dqxzh = ? and indate <= ? and indate >= ?";

String hql2 = "select count(*)*500 from TbHx where "+where+" dqxzh = ? ";

		List list = new ArrayList<CompareFund>();
		TbBankStaticsDAO bankStaticsDAO = new TbBankStaticsDAO();
		List baklist = bankStaticsDAO.findStaticRecord("", month);
		if(baklist == null || baklist.size()==0){
			log.error("没有这个月的数据");
            return null;
		}
		Iterator it = baklist.iterator();
		while(it.hasNext()){
			TbBankStatics bankStatics = (TbBankStatics)it.next();
			CompareFund compareFund = new CompareFund();
			compareFund.setRaName(bankStatics.getTbRajg().getRaName());
			compareFund.setIndate(bankStatics.getIndate());
		         compareFund.setIndateb(bankStatics.getIndateb());
                           compareFund.setAllmoney(bankStatics.getAllsum());
compareFund.setMonthmoney(bankStatics.getMonthmoney()+bankStatics.getMonthjust());
			compareFund.setYearmoney(bankStatics.getYearmoney());
		         Double monthys = getYs(hql1, bankStatics, true);
			
                           compareFund.setMonthys(monthys);
			
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(bankStatics.getIndateb());
			calendar.set(Calendar.MONTH,1);
			calendar.set(Calendar.DAY_OF_MONTH,1);
			bankStatics.setIndate(calendar.getTime());
		         Double yearys = getYs(hql1, bankStatics, true);
			compareFund.setYearys(yearys);
			
			Double allys = getYs(hql2, bankStatics, false);
	           	compareFund.setAllys(allys);
			
			compareFund.setAllmargin(allys-bankStatics.getAllsum());
			compareFund.setYearmargin(yearys-bankStatics.getYearmoney());
			compareFund.setMonthmargin(monthys-bankStatics.getMonthmoney()-bankStatics.getMonthjust());
			list.add(compareFund);
		}
		
		return list;
		
		}catch(RuntimeException re){
			throw re;
		}
	}
	
	public Double getYs(String hql,TbBankStatics bankStatics,boolean chooes ){
		Session session = null;
		try {
		session = getSession();
		Query q = session.createQuery(hql);
		q.setString(0, bankStatics.getTbRajg().getRaId());
		if(chooes){
			q.setDate(1, bankStatics.getIndate());
			q.setDate(2, bankStatics.getIndateb());
		}
		Double money = ((Integer)q.list().get(0)).doubleValue();
	
		return money;
		}catch(RuntimeException re){
			throw re;
		}finally{
			closeSession();//或者session.close()都不行
		}
	}
	
	
}


可以执行几次循环(不确定的,随机),然后就暴错 ERROR (JDBCExceptionReporter.java:72) - 关闭的语句: next
谁碰到过好郁闷.
   发表时间:2008-05-19  
你要注意,如果循环时间太长,就有可能让数据库主动和你断开连接。比如MySQL等数据库在连接时间过长的时候就肯能自动断开。
0 请登录后投票
   发表时间:2008-05-19  
魔力猫咪 写道
你要注意,如果循环时间太长,就有可能让数据库主动和你断开连接。比如MySQL等数据库在连接时间过长的时候就肯能自动断开。

时间不长 几秒钟就暴错了. 连接池配置
<?xml version="1.0" encoding="UTF-8"?>
<!-- the proxool configuration can be embedded within your own application's.
	Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
	<proxool>
		<alias>ozmax09</alias>
		<driver-url>
			jdbc:oracle:thin:@192.168.0.19:1521:ozmax09
		</driver-url>
		<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
		<driver-properties>
			<property name="user" value="****" />
			<property name="*****" value="zmxzmx" />
		</driver-properties>
		<house-keeping-test-sql>
			select sysdate from DUAL
		</house-keeping-test-sql>
		<house-keeping-sleep-time>90000</house-keeping-sleep-time>
		<maximum-new-connections>100</maximum-new-connections>
		<prototype-count>5</prototype-count>
		<maximum-connection-count>500</maximum-connection-count>
		<minimum-connection-count>0</minimum-connection-count>
		<maximum-active-time>0</maximum-active-time>
	</proxool>
</something-else-entirely>
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics