public List<FreeTrial> getFreeTrail() { List<FreeTrial> fr = new ArrayList<FreeTrial>(); try { String sql = "SELECT * FROM free_trial"; Connection con = DBFactory.getConnection(); PreparedStatement ps = con.prepareStatement(sql); ResultSet rs = ps.executeQuery(); while (rs.next()) { FreeTrial free = new FreeTrial(); free.setFreeId(rs.getInt(1)); free.setDays(rs.getInt(2)); free.setDownload_count(rs.getInt(3)); free.setPackage_type_id(rs.getInt(4)); fr.add(free); System.gc(); } } catch (Exception e) { e.printStackTrace(); } return fr; }
public FreeTrial getAFreeTrail(int package_type_id) { FreeTrial free = null; try { String sql = "SELECT * FROM free_trial WHERE package_type_id=?"; Connection con = DBFactory.getConnection(); PreparedStatement ps = con.prepareStatement(sql); ps.setInt(1, package_type_id); ResultSet rs = ps.executeQuery(); while (rs.next()) { free = new FreeTrial(); free.setFreeId(rs.getInt(1)); free.setDays(rs.getInt(2)); free.setDownload_count(rs.getInt(3)); free.setPackage_type_id(rs.getInt(4)); System.gc(); } } catch (Exception e) { e.printStackTrace(); } return free; }