use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableContext method reconnect.
@Override
protected void reconnect(Connection conn) throws DatabaseException {
try {
if (!DbUtils.hasTable(conn, TABLE_NAME)) {
// Need to create the table
DbUtils.executeAndClose(conn.prepareStatement("CREATE cached TABLE CONTEXT_DATA (dataid bigint generated by default as identity (start with 1), contextId int not null, type int not null, data varchar(8192) default '')"));
}
psRead = conn.prepareStatement("SELECT * FROM CONTEXT_DATA WHERE " + DATAID + " = ?");
psInsert = conn.prepareStatement("INSERT INTO CONTEXT_DATA (" + CONTEXTID + "," + TYPE + "," + DATA + ") VALUES (?, ?, ?)");
psGetIdLastInsert = conn.prepareCall("CALL IDENTITY();");
psDeleteData = conn.prepareStatement("DELETE FROM CONTEXT_DATA WHERE " + CONTEXTID + " = ? AND " + TYPE + " = ? AND " + DATA + " = ?");
psDeleteAllDataForContext = conn.prepareStatement("DELETE FROM CONTEXT_DATA WHERE " + CONTEXTID + " = ?");
psDeleteAllDataForContextAndType = conn.prepareStatement("DELETE FROM CONTEXT_DATA WHERE " + CONTEXTID + " = ? AND " + TYPE + " = ?");
psGetAllData = conn.prepareStatement("SELECT * FROM CONTEXT_DATA");
psGetAllDataForContext = conn.prepareStatement("SELECT * FROM CONTEXT_DATA WHERE " + CONTEXTID + " = ?");
psGetAllDataForContextAndType = conn.prepareStatement("SELECT * FROM CONTEXT_DATA WHERE " + CONTEXTID + " = ? AND " + TYPE + " = ?");
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableContext method deleteAllDataForContextAndType.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableContext#deleteAllDataForContextAndType(int, int)
*/
@Override
public synchronized void deleteAllDataForContextAndType(int contextId, int type) throws DatabaseException {
try {
psDeleteAllDataForContextAndType.setInt(1, contextId);
psDeleteAllDataForContextAndType.setInt(2, type);
psDeleteAllDataForContextAndType.executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableContext method getDataForContext.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableContext#getDataForContext(int)
*/
@Override
public synchronized List<RecordContext> getDataForContext(int contextId) throws DatabaseException {
try {
List<RecordContext> result = new ArrayList<>();
psGetAllDataForContext.setInt(1, contextId);
try (ResultSet rs = psGetAllDataForContext.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);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class MenuFileControl method openDbBasedSession.
private void openDbBasedSession() {
try {
List<String> sessionList = new ArrayList<String>();
for (RecordSession rs : model.getDb().getTableSession().listSessions()) {
sessionList.add("" + rs.getSessionId());
}
SessionTableSelectDialog ssd = new SessionTableSelectDialog(View.getSingleton().getMainFrame(), sessionList);
ssd.setVisible(true);
if (ssd.getSelectedSession() != null) {
waitMessageDialog = view.getWaitMessageDialog(Constant.messages.getString("menu.file.loadSession"));
control.openSession(ssd.getSelectedSession(), this);
waitMessageDialog.setVisible(true);
}
} catch (DatabaseException e) {
log.error(e.getMessage(), e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ActiveScan method notifyNewMessage.
@Override
public void notifyNewMessage(final HttpMessage msg) {
HistoryReference hRef = msg.getHistoryRef();
if (hRef == null) {
try {
hRef = new HistoryReference(Model.getSingleton().getSession(), HistoryReference.TYPE_SCANNER_TEMPORARY, msg);
msg.setHistoryRef(null);
hRefs.add(Integer.valueOf(hRef.getHistoryId()));
} catch (HttpMalformedHeaderException | DatabaseException e) {
log.error(e.getMessage(), e);
}
} else {
hRefs.add(Integer.valueOf(hRef.getHistoryId()));
}
this.rcTotals.incResponseCodeCount(msg.getResponseHeader().getStatusCode());
if (hRef != null && this.rcTotals.getTotal() <= this.maxResultsToList) {
// Very large lists significantly impact the UI responsiveness
// limiting them makes large scans _much_ quicker
addHistoryReference(hRef);
}
}
Aggregations