首页 > 代码库 > 典型用法--PreparedStatement

典型用法--PreparedStatement

 1 String sql2 = "select monid from monindex where groupname = ?"; 2         try { 3             PreparedStatement pre1 = conn.prepareStatement(sql2); 4             Iterator<String> it = groupnames.iterator(); 5             while (it.hasNext()) { 6                 HashSet<String> monids = new HashSet<String>(); 7                 String gname = it.next(); 8                 pre1.setString(1, gname); 9                 ResultSet rs = pre1.executeQuery();10                 while (rs.next()) {11                     monids.add(rs.getString(1));12                 }13                 groupcomein(gname, monids, day, begin, end);14                 logger.info("insert group " + gname + " data into DB");15             }16         } catch (SQLException e) {17             e.printStackTrace();18         }

 

典型用法--PreparedStatement