mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Update try catch to use try with resources
This commit is contained in:
parent
4378feedde
commit
f6976800f5
@ -431,23 +431,21 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteDeviceType(int tenantID, int deviceTypeId) throws DeviceManagementDAOException {
|
public void deleteDeviceType(int tenantID, int deviceTypeId) throws DeviceManagementDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
String sql = "DELETE FROM DM_DEVICE_TYPE" +
|
||||||
|
" WHERE" +
|
||||||
|
" ID = ?" +
|
||||||
|
" AND PROVIDER_TENANT_ID = ?";
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
String sql = "DELETE FROM DM_DEVICE_TYPE" +
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||||
" WHERE" +
|
stmt.setInt(1, deviceTypeId);
|
||||||
" ID = ?" +
|
stmt.setInt(2, tenantID);
|
||||||
" AND PROVIDER_TENANT_ID = ?";
|
stmt.execute();
|
||||||
stmt = conn.prepareStatement(sql);
|
}
|
||||||
stmt.setInt(1, deviceTypeId);
|
|
||||||
stmt.setInt(2, tenantID);
|
|
||||||
stmt.execute();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException(
|
throw new DeviceManagementDAOException(
|
||||||
"Error occurred while deleting device type of id: " + deviceTypeId +
|
"Error occurred while deleting device type of id: " + deviceTypeId +
|
||||||
" for tenant: " + tenantID, e);
|
" for tenant: " + tenantID, e);
|
||||||
} finally {
|
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user