stmt.executeQuery();
空指针错误!
Java code
public ArrayList getMMSSingleContent(String foreignid) {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
ArrayList<String> content = new ArrayList<String>();
try {
conn = IF_DBPool.getConnection();
if("".equals(conn)||conn==null){
log.info("conn is null!!");
}
log.info("SQL:"+DBStatement.SEND_TASK_SELECT_TBL_MMSINGLESENDContent);
stmt = conn.prepareStatement(DBStatement.SEND_TASK_SELECT_TBL_MMSINGLESENDContent);
if("".equals(stmt)||stmt==null){
log.info("stmt is null!!");
}
stmt.setString(1, foreignid);
log.info("SQL语句:select * from tbl_MMSingleSendCONTENT mms where foreignid ='"+ foreignid + "' order by foreignID,sequence");
rs = stmt.executeQuery();
log.info("executeQuery end!!");
while (rs.next()) {
log.info("MMSCONTENT:"+rs.getString("MMSCONTENT"));
content.add(rs.getString("MMSCONTENT"));
}
log.info("SQL end!");
} catch (Exception ex) {
log.error("fetch mmssinglecontent error:" + ex.getMessage(), ex);
} finally {
if (conn != null) {
try {
log.info("close begin!");
conn.close();
log.info("close end!");
} catch (SQLException e) {
log.error("C09 err:" + e.getMessage(), e);
}
}
}
return content;
}
因为我这边测试环境没有问题,现场有问题,所以使用现场的日志信息来判断错误原因!
日志如下:
INFO [Thread-2] [2011-10-25 13:40:47.669] (MMSFetchImp.java:363) SQL:select * from tbl_MMSingleSendCONTENT mms where foreignid = ? order by foreignID,sequence
INFO [Thread-2] [2011-10-25 13:40:47.670] (MMSFetchImp.java:371) SQL语句:select * from tbl_MMSingleSendCONTENT mms where foreignid ='111025134045381' order by foreignID,sequence
ERROR [Thread-2] [2011-10-25 13:40:47.689] (MMSFetchImp.java:382) fetch mmssinglecontent error:null
java.lang.NullPointerException at com.ibm.db2.jcc.b.zc.a(zc.java:1234)
at com.ibm.db2.jcc.a.db.n(db.java:589)
at com.ibm.db2.jcc.a.db.j(db.java:257)
at com.ibm.db2.jcc.a.db.c(db.java:57)
at com.ibm.db2.jcc.a.r.c(r.java:42)
at com.ibm.db2.jcc.a.sb.h(sb.java:169)
at com.ibm.db2.jcc.b.zc.p(zc.java:1223)
at com.ibm.db2.jcc.b.ad.d(ad.java:2246)
at com.ibm.db2.jcc.b.ad.U(ad.java:489)
at com.ibm.db2.jcc.b.ad.executeQuery(ad.java:472)
at com.***.utils.db.PooledPreparedStatement.executeQuery(PooledPreparedStatement.java:46)
at com.***.eie.mms.core.MMSFetchImp.getMMSSingleContent(MMSFetchImp.java:373)
at com.***.eie.mms.core.MMSDealImp.transferTaskToMMSSingleMessage(MMSDealImp.java:437)
at com.***.eie.mms.core.MMSDealImp.dispatchTaskToMessage(MMSDealImp.java:80)
at com.***.eie.mms.mmsthread.MMSDealThread.run(MMSDealThread.java:37)
日志可以看出执行完这一步后就出问题了。
log.info("SQL语句:select * from tbl_MMSingleSendCONTENT mms where foreignid ='"+ foreignid + "' order by foreignID,sequence");
所以
NullPointerExce