。。
public void run() {
while (true) {
try{
readList() ;
}catch(Exception e){
log().error("",e);
}
}
}
private List<CMPP2AbstractMessage> readList() {
Session ssn = null;
Connection con = null;
PreparedStatement pre = null;
ResultSet rs = null;
List<NewSmsBeenSentNumber> smsSent = new ArrayList<NewSmsBeenSentNumber>();
try {
//log().info("read data to send--->get the datebase session----->begin"); ssn = HibernateSessionFactory.currentSession();
//log().info("read data to send--->get the datebase session----->over!"); con = ssn.connection();
log().info("read data to send--->get the datebase conection--->over!");
String str = "select DN_NEEDREPLY, DC_SERVID, phoneId, DC_DST_ID, s.dn_id as dnSmsId, contentId, DC_EXTMARKID, dn_feeusertype,";
str += " DC_FEETERMID, nc.DN_FORMAT, dc_feeType, dc_feecode, dc_srcid, nc.DC_CONTENT, DN_PK_NUMBER, DN_PK_TOTAL";
str += " from";
str += " on s.dn_id = nc.dn_sms_id"; pre = con.prepareStatement(str);
pre.setQueryTimeout(60 * 2);//SQL语句执行超时时间为2分钟
log().info("query data-->begin");
rs = pre.executeQuery();
log().info("query data->return back");
while (rs.next())
{
NewSmsBeenSentNumber bean = new NewSmsBeenSentNumber();
int dnNeedreply = rs.getInt("DN_NEEDREPLY");
bean.setDnNeedRly(dnNeedreply);
String dcServId = rs.getString("DC_SERVID");
bean.setDcServid(dcServId);
.......
smsSent.add(bean);
}
} catch (Exception e) {
log().error("", e);
} finally {
try {
rs.close();
} catch (Exception e) {
}
try {
pre.close();
} catch (Exception e) {
}
HibernateSessionFactory.closeSession();
}
//
}问题是这样的 以上标红的两行 注释的log ,在注释的情况下程序运行效率非常慢,去掉注释效率很快,非常不解,求高人解释原因
解决方案 »
- 疑虑,java的学习
- 想从数据库取出一组字符型数据逐个与另一字符串比较
- 提示错误Exception in thread "main" java.lang.NullPointerException
- 疑难 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 请教大家一个问题!
- 关于限制上传图片尺寸的问题
- 请教:如何添加一个button到frame中,并捕获其点击事件??
- java.awt.* 和javax.awt.*有什麼區別?
- 为什麽不能显示小应用程序?
- 怎样配置ibm websphere application server 使它能支持*.shtml 文件??请各位大虾予以指教!!!
- 抽象类有什么用?
- JAVA GUI问题请教大家
private Logger log() {
return ThreadLogger.getInstance();
}
Logger log = log();
后面就直接用log变量,避免重复调用了。