int[] findVMsInGroup(String groupID)
throws WorkspaceDatabaseException {
if (groupID == null) {
throw new WorkspaceDatabaseException("groupID is null");
}
Connection c = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
c = getConnection();
pstmt = c.prepareStatement(SQL_SELECT_ALL_VMS_IN_GROUP);
pstmt.setString(1, groupID);
rs = pstmt.executeQuery();
if (rs == null || !rs.next()) {
logger.debug("no VMs found with groupID = " + groupID);
return zeroLen;
}
final ArrayList vmidsList = new ArrayList(64);
do {
vmidsList.add(new Integer(rs.getInt(1)));
} while (rs.next());
// can't use toArray without converting to Integer[]
final int[] ret = new int[vmidsList.size()];
for (int i = 0; i < ret.length; i++) {
ret[i] = ((Number) vmidsList.get(i)).intValue();
}
return ret;
} catch(SQLException e) {
logger.error("",e);
throw new WorkspaceDatabaseException(e);
} finally {
try {
if (rs != null) {
rs.close();
}