use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableStructure method getChildren.
@Override
public List<RecordStructure> getChildren(long sessionId, long parentId) throws DatabaseException {
try {
psGetChildren.setLong(1, sessionId);
psGetChildren.setLong(2, parentId);
List<RecordStructure> result = new ArrayList<>();
try (ResultSet rs = psGetChildren.executeQuery()) {
while (rs.next()) {
result.add(build(rs));
}
}
return result;
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableTag 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 TAG (tagid bigint generated by default as identity (start with 1), historyid bigint not null, tag varchar(1024) default '')"));
}
psRead = conn.prepareStatement("SELECT * FROM TAG WHERE " + TAGID + " = ?");
psInsertTag = conn.prepareStatement("INSERT INTO TAG (" + HISTORYID + "," + TAG + ") VALUES (?, ?)");
psGetIdLastInsert = conn.prepareCall("CALL IDENTITY();");
psDeleteTag = conn.prepareStatement("DELETE FROM TAG WHERE " + HISTORYID + " = ? AND " + TAG + " = ?");
psGetTagsForHistoryId = conn.prepareStatement("SELECT * FROM TAG WHERE " + HISTORYID + " = ?");
psDeleteTagsForHistoryId = conn.prepareStatement("DELETE FROM TAG WHERE " + HISTORYID + " = ?");
psGetAllTags = conn.prepareStatement("SELECT DISTINCT TAG FROM TAG ORDER BY TAG");
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableHistory method read.
@Override
public synchronized RecordHistory read(int historyId) throws HttpMalformedHeaderException, DatabaseException {
try {
psRead.setInt(1, historyId);
psRead.execute();
RecordHistory result = null;
try (ResultSet rs = psRead.getResultSet()) {
result = build(rs);
}
return result;
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableHistory method updateNote.
@Override
public synchronized void updateNote(int historyId, String note) throws DatabaseException {
try {
psUpdateNote.setString(1, note);
psUpdateNote.setInt(2, historyId);
psUpdateNote.execute();
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableHistory method write.
@Override
public synchronized RecordHistory write(long sessionId, int histType, HttpMessage msg) throws HttpMalformedHeaderException, DatabaseException {
try {
String reqHeader = "";
byte[] reqBody = new byte[0];
String resHeader = "";
byte[] resBody = reqBody;
String method = "";
String uri = "";
int statusCode = 0;
String note = msg.getNote();
if (!msg.getRequestHeader().isEmpty()) {
reqHeader = msg.getRequestHeader().toString();
reqBody = msg.getRequestBody().getBytes();
method = msg.getRequestHeader().getMethod();
uri = msg.getRequestHeader().getURI().toString();
}
if (!msg.getResponseHeader().isEmpty()) {
resHeader = msg.getResponseHeader().toString();
resBody = msg.getResponseBody().getBytes();
statusCode = msg.getResponseHeader().getStatusCode();
}
//return write(sessionId, histType, msg.getTimeSentMillis(), msg.getTimeElapsedMillis(), method, uri, statusCode, reqHeader, reqBody, resHeader, resBody, msg.getTag());
return write(sessionId, histType, msg.getTimeSentMillis(), msg.getTimeElapsedMillis(), method, uri, statusCode, reqHeader, reqBody, resHeader, resBody, null, note, msg.isResponseFromTargetHost());
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
Aggregations