Fix device enrolment and syncing with MSSQL db #113
Merged
tcdlpds
merged 5 commits from prathabanKavin/device-mgt-core:mssqlenrolmentfix2
into master
2 years ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'prathabanKavin/device-mgt-core:mssqlenrolmentfix2'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Purpose
Details
Connection connection = OperationManagementDAOFactory.getConnection();
String sql = "INSERT INTO DM_OPERATION(TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, " +
"INITIATED_BY, OPERATION_DETAILS) VALUES (?, ?, ?, ?, ?, ?)";
stmt = connection.prepareStatement(sql, new String[]{"id"});
Use try with resources.
Use try with resources.
throw new OperationManagementDAOException("Error occurred while adding command operation", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt);
OperationManagementDAOUtil.cleanupResources(stmt, rs);
When you do modifications with try with resources, you can remove this finally block.
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT OPERATION_ID, ENABLED, OPERATION_CONFIG FROM DM_CONFIG_OPERATION WHERE OPERATION_ID = ?";
String sql = "SELECT ID, ENABLED, OPERATION_DETAILS FROM DM_OPERATION WHERE ID = ? AND TYPE='CONFIG'";
stmt = conn.prepareStatement(sql);
Use try with resources
"AND STATUS = ?) dm ON dm.OPERATION_ID = co.OPERATION_ID";
"AND STATUS = ?) dm ON dm.OPERATION_ID = co.ID WHERE co.TYPE = 'CONFIG'";
stmt = conn.prepareStatement(sql);
Use try with resources.
operations.add(configOperation);
}
} catch (IOException e) {
throw new OperationManagementDAOException("IO Error occurred while de serialize the configuration " +
Log the error
} finally {
OperationManagementDAOUtil.cleanupResources(stmt);
String msg = "Error occurred while adding command operation" + e;
log.error(msg);
log error as well. E.g - log.error(msg, e)
OperationManagementDAOUtil.cleanupResources(stmt);
String msg = "Error occurred while adding command operation" + e;
log.error(msg);
throw new OperationManagementDAOException(msg);
Throw error, e.g - throw new OperationManagementDAOException(msg, e);
} catch (IOException e) {
String msg = "IO Error occurred while de serialize the policy operation " +
"object" + e;
log.error(msg);
Log and throw error as well.
} catch (ClassNotFoundException e) {
String msg = "Class not found error occurred while de serialize the policy " +
"operation object" + e;
log.error(msg);
Log and throw error as well.
} catch (IOException e) {
String msg = "IO Error occurred while de serialize the configuration " +
"operation object" + e;
log.error(msg);
Log and throw error as well
} catch (ClassNotFoundException e) {
String msg = "Class not found error occurred while de serialize the " +
"configuration operation object" + e;
log.error(msg);
Log and throw error as well
bd35583737
into master 2 years agoReviewers
bd35583737
.