Connection con = this.createConnection( dsName );
PreparedStatement pStmt=null;
try
{
con.setAutoCommit(false);
QueryManager qManager = QueryManager.getInstance();
/* Check if there is any Dist group with same name */
String sql;
sql = qManager.getDuplicateDistGroupUpdateQuery(dbType);
pStmt = con.prepareStatement( sql );
pStmt.setString( 1, distGroupVO.getId() );
pStmt.setString( 2, distGroupVO.getDistGroupName() );
ResultSet rset = null;
rset = pStmt.executeQuery();
if( rset.next() ){
if(rset.getInt(1)>0){
DAOException daox = new DAOException ("Database Error");
daox.setMessageKey(IErrorMessageKeys.KEY_ERROR_DUPLICATE_DIST_GROUP);
throw daox;
}
}
sql = qManager.getUpdateDistGroupQuery(dbType);
log.debug(sql);
pStmt = con.prepareStatement( sql );
pStmt.setString( 1, distGroupVO.getDistGroupName() );
pStmt.setString( 2, distGroupVO.getDistGroupDesc() );
pStmt.setString( 3, distGroupVO.getIsEnabled());
pStmt.setString( 4, distGroupVO.getId());
pStmt.executeUpdate();
this.createSearchContent(con,dbType,distGroupVO,"TBL_DISTRIBUTION_GROUP","GROUP_ID");
//first delete old users
sql = qManager.getDeleteDistGroupUserQuery(dbType);
pStmt = con.prepareStatement( sql );
pStmt.setString( 1, distGroupVO.getId());
pStmt.executeUpdate();
String[] userIds = EEMSUtil.convertToArray(distGroupVO.getUserNames(),IConstants.EEMS_DELIMITER);
if(userIds!=null)
{
sql = qManager.getFetchDistGroupUserQuery(dbType);
pStmt = con.prepareStatement( sql );
log.debug(sql);
for (int i=0; i<userIds.length;i++)
{