我现在将表1使用存储过程转变成表2存储过程为:declare @sql nvarchar(1000)
set @sql='select examineeId,examineeName,'
select @sql=@sql+'sum(case appraisalName when '''+appraisalName+''' then result else 0 end) as '+appraisalName+',' from
(select distinct appraisalName from finalresult) t
set @sql=LEFT(@sql,len(@sql)-1)+' from finalresult group by examineeId,examineeName'
exec(@sql)我现在的问题是:如何使用java将用存储过程得到的表2输出,请写出java类,尤其是调用存储过程的部分以及rs的输出实例。
例:Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
conn = DB.getConn();
stmt = conn.createStatement();
....(这边怎么写?还有stmt的类型好像也不对)
while(rs.next()){
...(得到rs,rs如何输出,还是rs.getString()之类的?还是使用列数输出,如何使用列数输出)
}
}
catch(Exception e){
e.printStackTrace();
}
finally{
DB.closeRs(rs);
DB.closeStmt(stmt);
DB.closeConn(conn);
}
忘不吝赐教,谢谢!
set @sql='select examineeId,examineeName,'
select @sql=@sql+'sum(case appraisalName when '''+appraisalName+''' then result else 0 end) as '+appraisalName+',' from
(select distinct appraisalName from finalresult) t
set @sql=LEFT(@sql,len(@sql)-1)+' from finalresult group by examineeId,examineeName'
exec(@sql)我现在的问题是:如何使用java将用存储过程得到的表2输出,请写出java类,尤其是调用存储过程的部分以及rs的输出实例。
例:Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
conn = DB.getConn();
stmt = conn.createStatement();
....(这边怎么写?还有stmt的类型好像也不对)
while(rs.next()){
...(得到rs,rs如何输出,还是rs.getString()之类的?还是使用列数输出,如何使用列数输出)
}
}
catch(Exception e){
e.printStackTrace();
}
finally{
DB.closeRs(rs);
DB.closeStmt(stmt);
DB.closeConn(conn);
}
忘不吝赐教,谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货