use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class SqlTableParam method update.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableParam#update(long, int, java.lang.String, java.lang.String)
*/
@Override
public synchronized void update(long paramId, int used, String flags, String values) throws DatabaseException {
SqlPreparedStatementWrapper psUpdate = null;
try {
psUpdate = DbSQL.getSingleton().getPreparedStatement("param.ps.update");
psUpdate.getPs().setInt(1, used);
psUpdate.getPs().setString(2, flags);
psUpdate.getPs().setString(3, values);
psUpdate.getPs().setLong(4, paramId);
psUpdate.getPs().executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psUpdate);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class SqlTableScan method read.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableScan#read(int)
*/
@Override
public synchronized RecordScan read(int scanId) throws DatabaseException {
SqlPreparedStatementWrapper psRead = null;
try {
psRead = DbSQL.getSingleton().getPreparedStatement("scan.ps.read");
psRead.getPs().setInt(1, scanId);
try (ResultSet rs = psRead.getPs().executeQuery()) {
RecordScan result = build(rs);
return result;
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psRead);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class SqlTableAlert method updateTable.
// ZAP: Added the method.
private void updateTable(Connection connection) throws DatabaseException {
try {
// Add the SOURCEHISTORYID column to the db if necessary
if (!DbUtils.hasColumn(connection, TABLE_NAME, SOURCEHISTORYID)) {
DbUtils.executeAndClose(connection.prepareStatement(DbSQL.getSQL("alert.ps.addsourcehistoryid")));
}
// Add the ATTACK column to the db if necessary
if (!DbUtils.hasColumn(connection, TABLE_NAME, ATTACK)) {
DbUtils.executeAndClose(connection.prepareStatement(DbSQL.getSQL("alert.ps.addattack")));
}
if (!DbUtils.hasColumn(connection, TABLE_NAME, EVIDENCE)) {
// Evidence, cweId and wascId all added at the same time
DbUtils.executeAndClose(connection.prepareStatement(DbSQL.getSQL("alert.ps.addevidence")));
DbUtils.executeAndClose(connection.prepareStatement(DbSQL.getSQL("alert.ps.addcweid")));
DbUtils.executeAndClose(connection.prepareStatement(DbSQL.getSQL("alert.ps.addwascid")));
}
if (!DbUtils.hasIndex(connection, TABLE_NAME, ALERT_INDEX)) {
// this speads up session loading
DbUtils.executeAndClose(connection.prepareStatement(DbSQL.getSQL("alert.ps.addalertindex")));
}
if (!DbUtils.hasColumn(connection, TABLE_NAME, SOURCEID)) {
DbUtils.executeAndClose(connection.prepareStatement(DbSQL.getSQL("alert.ps.addsourceid")));
DbUtils.executeAndClose(connection.prepareStatement(DbSQL.getSQL("alert.ps.addsourceidindex")));
}
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class SqlTableContext 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 {
SqlPreparedStatementWrapper psDeleteAllDataForContextAndType = null;
try {
psDeleteAllDataForContextAndType = DbSQL.getSingleton().getPreparedStatement("context.ps.alldataforcontexttype");
psDeleteAllDataForContextAndType.getPs().setInt(1, contextId);
psDeleteAllDataForContextAndType.getPs().setInt(2, type);
psDeleteAllDataForContextAndType.getPs().executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psDeleteAllDataForContextAndType);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class SqlTableContext method deleteAllDataForContext.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableContext#deleteAllDataForContext(int)
*/
@Override
public synchronized void deleteAllDataForContext(int contextId) throws DatabaseException {
SqlPreparedStatementWrapper psDeleteAllDataForContext = null;
try {
psDeleteAllDataForContext = DbSQL.getSingleton().getPreparedStatement("context.ps.alldataforcontext");
psDeleteAllDataForContext.getPs().setInt(1, contextId);
psDeleteAllDataForContext.getPs().executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psDeleteAllDataForContext);
}
}
Aggregations