`
eclipseakwolf
  • 浏览: 6813 次
  • 性别: Icon_minigender_1
  • 来自: 琼海
社区版块
存档分类
最新评论

小问题

阅读更多
1、Cannot load JDBC driver class 'com.mysql.jdbc.Driver
lib中已加入jar包,还是报错,后来把jar包放入tomcat lib目录下,问题解决,记录一下


2、oracle分页
select * from

(select a.*,rownum row_num from

(select * from mytable t order by t.id desc) a

) b where b.row_num between 1 and 10



3、oracle(ORA-01000: maximum open cursors exceeded)错误

出现在多个ReusltSet循环中,在嵌套的rs循环中执行完一个statement操作之后,都对其进行关闭
public void releaseStmt(){
	if(this.stmt!=null){
		try {
			this.stmt.close() ;
			this.stmt = null ;
		} catch (SQLException e) {
			e.printStackTrace();
		}
			
	}
}

while(rs.next()){
	addDate = TimeUtil.getDateTime(new Date()) ;
	jszgh = rs.getString("JSZGH") ;
	kcdm = rs.getString("KCDM") ;
	xh = rs.getString("XH") ;
	sql = "select * from GXJXGL.XSPFB20102 where XN='"+xn+"' and XQ="+xq+" and XH='"+xh+"' and JSZGH='"+jszgh+"' and KCDM='"+kcdm+"'" ;
	
	
	finalRs =db.getResult(sql) ;				
	while(finalRs.next()){						
		xkkh = finalRs.getString("XKKH") ;
		pjsj = finalRs.getDate("PJSJ") ;
		pjh = finalRs.getInt("PJH") ;					
		//pf = finalRs.getDouble("PF") ;		
		dj = finalRs.getString("DJ") ;
		if("优".equals(dj)){
			pf = 95 ;
		}else if("良".equals(dj)){
			pf = 85 ;
		}else if("中".equals(dj)){
			pf = 75 ;
		}else if("及格".equals(dj)){
			pf = 65 ;
		}else{
			pf = 55 ;
		}
		switch (pjh) {
			case 1:
			case 2:
			case 5:
			case 7:
			case 8:
			case 9:
			case 10:
				pjzf +=  pf*0.1 ; 
				break;
			case 3:
				pjzf +=  pf*0.2 ;
				break;
			case 4:
			case 6:
				pjzf += pf*0.05 ; 
				break;
		}
	}
	finalRs.close() ;
	db.releaseStmt() ;	
	
	
	sql = "select count(PJID),PJID from GXJXGL.STAT_XSPJB where XN='"+xn+"' and XQ="+xq+" and XH='"+xh+"' and JSZGH='"+jszgh+"' and KCDM='"+kcdm+"' group by PJID" ;
	queryRs = db.getResult(sql) ;
	if(queryRs.next()){
		if(queryRs.getInt(1)>0){
			f = queryRs.getInt("PJID") ;
		}
	}
	queryRs.close() ;
	db.releaseStmt() ;
	
	
	if(f==-1){
		sql = "insert into GXJXGL.STAT_XSPJB(PJID,XN,XQ,XH,XKKH,JSZGH,PJSJ,KCDM,PJZF,ADDDATE) values(GXJXGL.PJID.nextVal,'"+xn+"','"+xq+"','"+xh+"','"+xkkh+"','"+jszgh+"',TO_DATE('"+pjsj+"', 'YYYY-MM-DD'),'"+kcdm+"',"+pjzf+",TO_TIMESTAMP('"+addDate+"', 'YYYY-MM-DD HH24:MI:SS'))" ;
	}else{
		sql = "update GXJXGL.STAT_XSPJB set XH='"+xh+"',XKKH='"+xkkh+"',PJZF="+pjzf+",ADDDATE=TO_TIMESTAMP('"+addDate+"','YYYY-MM-DD HH24:MI:SS') where PJID="+f ;
	}
	
	db.executeSql(sql) ;
	db.releaseStmt() ;
	
	//显示
	//System.out.println((count++));				
	pjzf = 0 ;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics