added a database check to ensure data exists - this replaces an older method and reduces startup time to help resolve issue #168

Former-commit-id: 4a8b2db9adf91cef2d89148f0c9b9c2327240221
This commit is contained in:
Jeremy Long
2014-11-25 05:55:01 -05:00
parent 0d90b676bc
commit ab4b19dbab

View File

@@ -700,6 +700,31 @@ public class CveDB {
}
}
/**
* Checks to see if data exists so that analysis can be performed.
*
* @return <code>true</code if data exists; otherwise <code>false</code>
*/
public boolean dataExists() {
Statement cs = null;
ResultSet rs = null;
try {
cs = conn.createStatement();
rs = cs.executeQuery("SELECT COUNT(*) records FROM cpeEntry");
if (rs.next()) {
if (rs.getInt(1) > 0) {
return true;
}
}
} catch (SQLException ex) {
Logger.getLogger(CveDB.class.getName()).log(Level.SEVERE, null, ex);
} finally {
DBUtils.closeResultSet(rs);
DBUtils.closeStatement(cs);
}
return false;
}
/**
* It is possible that orphaned rows may be generated during database updates. This should be called after all
* updates have been completed to ensure orphan entries are removed.