message_list.jsp:
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.sql.*,java.util.*,javabean.Message"%>
<%
Message mes_temp = new Message();
String sql_temp = "select message_id from message ";
String front_id_string = mes_temp.excuteTempSql(sql_temp);
out.print(front_id_string);
%>
Message.java:
package javabean;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import db.DBUtil;
public class Message {
private int message_id;
private String nickname;
private String photo_select;
private String qq;
private String email;
private String tel;
private String content;
private Timestamp message_addedtime;
private String content_reply;
private Connection conn;
private ResultSet rs;
private Statement stmt;
private String front_id_string;
public String excuteTempSql(String sql_temp){
//conn不为null
conn = DBUtil.getConnection();
try {
//断点调试到此处时,stmt为null?
stmt = conn.createStatement();
rs = stmt.executeQuery(sql_temp);
while (rs.next()) {
front_id_string = front_id_string + rs.getInt("checkin_id") + ",";
}
} catch (SQLException e) {
e.printStackTrace();
}
return front_id_string;
}
}
问题:注释部分。