Merge pull request #1130 from ruwany/master

Fixing server startup issue when configured with PostgreSQL DB
revert-70aa11f8
Milan Perera 7 years ago committed by GitHub
commit b1a65b88ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -39,6 +39,34 @@ import java.util.List;
*/
public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl {
@Override
public int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs;
int groupId = -1;
try {
Connection conn = GroupManagementDAOFactory.getConnection();
String sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID) " +
"VALUES (?, ?, ?, ?) RETURNING ID";
stmt = conn.prepareStatement(sql);
stmt.setString(1, deviceGroup.getDescription());
stmt.setString(2, deviceGroup.getName());
stmt.setString(3, deviceGroup.getOwner());
stmt.setInt(4, tenantId);
stmt.execute();
rs = stmt.getGeneratedKeys();
if (rs.next()) {
groupId = rs.getInt(1);
}
return groupId;
} catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" +
deviceGroup.getName() + "'", e);
} finally {
GroupManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public List<DeviceGroup> getGroups(GroupPaginationRequest request, int tenantId)
throws GroupManagementDAOException {

Loading…
Cancel
Save