Javabean+jsp+jdbc传值问题

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;
    }

}

问题:注释部分。

1个回答

你可以加断点调试一下

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问