Skip to content

Commit

Permalink
removed unused code for batching
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylong committed Mar 11, 2017
1 parent 46f227e commit 318f3e1
Showing 1 changed file with 9 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ public final class CveDB {
* table.
*/
private DatabaseProperties databaseProperties;
/**
* Does the underlying connection support batch operations? Currently we do
* not support batch execution.
*/
private final boolean batchSupported = false;
/**
* The prepared statements.
*/
Expand Down Expand Up @@ -623,30 +618,14 @@ public synchronized void updateVulnerability(Vulnerability vuln) throws Database
}

final PreparedStatement insertReference = getPreparedStatement(INSERT_REFERENCE);
if (batchSupported) {
insertReference.clearBatch();
}
for (Reference r : vuln.getReferences()) {
insertReference.setInt(1, vulnerabilityId);
insertReference.setString(2, r.getName());
insertReference.setString(3, r.getUrl());
insertReference.setString(4, r.getSource());

if (batchSupported) {
insertReference.addBatch();
} else {
insertReference.execute();
}
}

if (batchSupported) {
insertReference.executeBatch();
insertReference.execute();
}

final PreparedStatement insertSoftware = getPreparedStatement(INSERT_SOFTWARE);
if (batchSupported) {
insertSoftware.clearBatch();
}
for (VulnerableSoftware s : vuln.getVulnerableSoftware()) {
int cpeProductId = 0;
final PreparedStatement selectCpeId = getPreparedStatement(SELECT_CPE_ID);
Expand Down Expand Up @@ -682,24 +661,17 @@ public synchronized void updateVulnerability(Vulnerability vuln) throws Database
} else {
insertSoftware.setString(3, s.getPreviousVersion());
}
if (batchSupported) {
insertSoftware.addBatch();
} else {
try {
insertSoftware.execute();
} catch (SQLException ex) {
if (ex.getMessage().contains("Duplicate entry")) {
final String msg = String.format("Duplicate software key identified in '%s:%s'", vuln.getName(), s.getName());
LOGGER.info(msg, ex);
} else {
throw ex;
}
try {
insertSoftware.execute();
} catch (SQLException ex) {
if (ex.getMessage().contains("Duplicate entry")) {
final String msg = String.format("Duplicate software key identified in '%s:%s'", vuln.getName(), s.getName());
LOGGER.info(msg, ex);
} else {
throw ex;
}
}
}
if (batchSupported) {
insertSoftware.executeBatch();
}
} catch (SQLException ex) {
final String msg = String.format("Error updating '%s'", vuln.getName());
LOGGER.debug(msg, ex);
Expand Down

0 comments on commit 318f3e1

Please sign in to comment.