use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableTag method getTagsForHistoryID.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableTag#getTagsForHistoryID(long)
*/
@Override
public synchronized List<RecordTag> getTagsForHistoryID(long historyId) throws DatabaseException {
try {
List<RecordTag> result = new ArrayList<>();
psGetTagsForHistoryId.setLong(1, historyId);
try (ResultSet rs = psGetTagsForHistoryId.executeQuery()) {
while (rs.next()) {
result.add(new RecordTag(rs.getLong(TAGID), rs.getLong(TAGID), rs.getString(TAG)));
}
}
return result;
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableScan method insert.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableScan#insert(long, java.lang.String)
*/
@Override
public synchronized RecordScan insert(long sessionId, String scanName) throws DatabaseException {
try {
psInsert.setLong(1, sessionId);
psInsert.setString(2, scanName);
psInsert.executeUpdate();
int id;
try (ResultSet rs = psGetIdLastInsert.executeQuery()) {
rs.next();
id = rs.getInt(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 ParosTableScan method build.
private RecordScan build(ResultSet rs) throws DatabaseException {
try {
RecordScan scan = null;
if (rs.next()) {
scan = new RecordScan(rs.getInt(SCANID), rs.getString(SCANNAME), rs.getDate(SCANTIME));
}
rs.close();
return scan;
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableSession method insert.
/*
public synchronized RecordSession read(long sessionId) throws HttpMalformedHeaderException, SQLException {
psRead.setInt(1, historyId);
psRead.execute();
ResultSet rs = psRead.getResultSet();
return build(rs);
}
*/
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableSession#insert(long, java.lang.String)
*/
@Override
public synchronized void insert(long sessionId, String sessionName) throws DatabaseException {
try {
psInsert.setLong(1, sessionId);
psInsert.setString(2, sessionName);
psInsert.executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ParosTableSession method reconnect.
@Override
protected void reconnect(Connection conn) throws DatabaseException {
try {
psReadDate = conn.prepareStatement("SELECT * FROM SESSION WHERE " + LASTACCESS + " < ?");
psReadAll = conn.prepareStatement("SELECT * FROM SESSION");
psInsert = conn.prepareStatement("INSERT INTO SESSION (" + SESSIONID + "," + SESSIONNAME + ") VALUES (?, ?)");
psUpdate = conn.prepareStatement("UPDATE SESSION SET " + SESSIONNAME + " = ?," + LASTACCESS + " = NOW " + "WHERE " + SESSIONID + " = ?");
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
Aggregations