日期:2014-05-16 浏览次数:20642 次
public List<Terminal> getTerm(String user){ List<Terminal> termlist= null;//这里出现问题,没有new一个List //改为List<Terminal> termlist= new ArrayList();, //new一个ArrayList就没事了,日,以前初学的时候也得过这种问题...汗 try { con = DBPool.getPool().getConnection(); ps =con.prepareStatement("select * from gps_termcodetable where kh_user=?"); ps.setString(1, user); rs = ps.executeQuery(); while(rs.next()){ Terminal term = new Terminal(); String number = rs.getString("hm_number"); String nick = rs.getString("mc_nick"); term.setZhNumber(number); term.setLisence(rs.getString("mc_nick")); termlist.add(term); } rs.close(); ps.close(); con.close(); } catch (SQLException ex) { Logger.getLogger(GetTerminal.class.getName()).log(Level.SEVERE, null, ex); } return termlist; }