use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableAlert method reconnect.
@Override
protected void reconnect(Connection conn) throws DatabaseException {
try {
// ZAP: Changed to call the method updateTable(Connection).
updateTable(conn);
psRead = conn.prepareStatement("SELECT TOP 1 * FROM " + TABLE_NAME + " WHERE " + ALERTID + " = ?");
psInsert = conn.prepareStatement("INSERT INTO " + TABLE_NAME + " (" + SCANID + "," + PLUGINID + "," + ALERT + "," + RISK + "," + RELIABILITY + "," + DESCRIPTION + "," + URI + "," + PARAM + "," + ATTACK + "," + OTHERINFO + "," + SOLUTION + "," + REFERENCE + "," + EVIDENCE + "," + CWEID + "," + WASCID + "," + HISTORYID + "," + SOURCEHISTORYID + "," + SOURCEID + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
psGetIdLastInsert = conn.prepareCall("CALL IDENTITY();");
psDeleteAlert = conn.prepareStatement("DELETE FROM " + TABLE_NAME + " WHERE " + ALERTID + " = ?");
psDeleteAllAlerts = conn.prepareStatement("DELETE FROM " + TABLE_NAME);
//psDeleteScan = conn.prepareStatement("DELETE FROM ALERT WHERE " + SCANID + " = ?");
// ZAP: New prepared statement for updating an alert
psUpdate = conn.prepareStatement("UPDATE " + TABLE_NAME + " SET " + ALERT + " = ?, " + RISK + " = ?," + RELIABILITY + " = ?," + DESCRIPTION + " = ?," + URI + " = ?," + PARAM + " = ?," + ATTACK + " = ?," + OTHERINFO + " = ?," + SOLUTION + " = ?," + REFERENCE + " = ?, " + EVIDENCE + " = ?, " + CWEID + " = ?, " + WASCID + " = ?, " + SOURCEHISTORYID + " = ? " + "WHERE " + ALERTID + " = ?");
psUpdateHistoryIds = conn.prepareStatement("UPDATE " + TABLE_NAME + " SET " + HISTORYID + " = ?, " + SOURCEHISTORYID + " = ? " + "WHERE " + ALERTID + " = ?");
psGetAlertsForHistoryId = conn.prepareStatement("SELECT * FROM " + TABLE_NAME + " WHERE " + SOURCEHISTORYID + " = ?");
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableAlert method deleteAlert.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableAlert#deleteAlert(int)
*/
@Override
public synchronized void deleteAlert(int alertId) throws DatabaseException {
try {
psDeleteAlert.setInt(1, alertId);
psDeleteAlert.execute();
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableContext method deleteAllDataForContext.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableContext#deleteAllDataForContext(int)
*/
@Override
public synchronized void deleteAllDataForContext(int contextId) throws DatabaseException {
try {
psDeleteAllDataForContext.setInt(1, contextId);
psDeleteAllDataForContext.executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableContext method insert.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableContext#insert(int, int, java.lang.String)
*/
@Override
public synchronized RecordContext insert(int contextId, int type, String url) throws DatabaseException {
try {
psInsert.setInt(1, contextId);
psInsert.setInt(2, type);
psInsert.setString(3, url);
psInsert.executeUpdate();
long id;
try (ResultSet rs = psGetIdLastInsert.executeQuery()) {
rs.next();
id = rs.getLong(1);
}
return read(id);
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableContext method getDataForContextAndType.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableContext#getDataForContextAndType(int, int)
*/
@Override
public synchronized List<RecordContext> getDataForContextAndType(int contextId, int type) throws DatabaseException {
try {
List<RecordContext> result = new ArrayList<>();
psGetAllDataForContextAndType.setInt(1, contextId);
psGetAllDataForContextAndType.setInt(2, type);
try (ResultSet rs = psGetAllDataForContextAndType.executeQuery()) {
while (rs.next()) {
result.add(new RecordContext(rs.getLong(DATAID), rs.getInt(CONTEXTID), rs.getInt(TYPE), rs.getString(DATA)));
}
}
return result;
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
Aggregations