mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #1130 from ruwany/master
Fixing server startup issue when configured with PostgreSQL DB
This commit is contained in:
commit
b1a65b88ee
@ -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…
Reference in New Issue
Block a user