当显示包含来自数据库的数据的列表时,将显示Null

时间:2014-12-11 06:11:00

标签: java list

我是java的新手,这个问题可能早先被问过,但我没有得到确切的答案。我想将数据库中的数据添加到at并通过jsp显示。但是显示空值或空值,即没有显示数据,当我执行sql server中的代码中使用的相同sql查询时,则显示所需的输出。 我的java代码是:



public List < Alarm_Bean > get_Count(String system_Name)

{

  if (system_Name.equals("MPS"))

  {
    try {
      con = getConnection();

      stmt = con.createStatement();

      String sql = " select system_name,COUNT(distinct arrival_time) AS c from i2alarmlog where Ack_status=0 AND Direction='CAME' and system_name in( 'I2-tciu database','i2-mps database') group by system_name union all select 'sum' system_name, Count(distinct arrival_time) from i2alarmlog where Ack_status=0 AND Direction='CAME' and system_name in( 'I2-tciu database','i2-mps database')   ";

      stmt.executeQuery(sql);
      rs = stmt.getResultSet();



      while (rs.next()) {
        Alarm_Bean obj = new Alarm_Bean();


        obj.setSystem_name(rs.getString("system_name"));

        obj.setC(rs.getString("c"));
        at.add(obj);
      }

    } catch (Exception e) {
      System.out.println("\nException " + e);
    } finally {
      closeConnection(stmt, rs, con);
    }
  }
  //System.out.println(at);

  return at;

}
&#13;
&#13;
&#13;

Jsp代码是: -

<c:out value="${ab.get_Count(MPS)}"></c:out>

0 个答案:

没有答案