Search in sources :

Example 21 with DataAccessException

use of org.xipki.datasource.DataAccessException in project xipki by xipki.

the class DbToolBase method deleteFromTableWithLargerId.

public boolean deleteFromTableWithLargerId(String tableName, String idColumn, long id, Logger log) {
    ParamUtil.requireNonBlank("tableName", tableName);
    ParamUtil.requireNonBlank("idColumn", idColumn);
    String sql = StringUtil.concatObjects("DELETE FROM ", tableName, " WHERE ", idColumn, ">", id);
    Statement stmt;
    try {
        stmt = createStatement();
    } catch (DataAccessException ex) {
        log.error("could not create statement", ex);
        return false;
    }
    try {
        stmt.execute(sql);
    } catch (Throwable th) {
        String msg = String.format("could not delete columns from table %s with %s > %s", tableName, idColumn, id);
        LogUtil.error(log, th, msg);
        return false;
    } finally {
        releaseResources(stmt, null);
    }
    return true;
}
Also used : PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) DataAccessException(org.xipki.datasource.DataAccessException)

Aggregations

DataAccessException (org.xipki.datasource.DataAccessException)21 PreparedStatement (java.sql.PreparedStatement)18 SQLException (java.sql.SQLException)14 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)9 ResultSet (java.sql.ResultSet)6 Connection (java.sql.Connection)5 BigInteger (java.math.BigInteger)3 CertificateEncodingException (java.security.cert.CertificateEncodingException)3 CertificateException (java.security.cert.CertificateException)3 X509Certificate (java.security.cert.X509Certificate)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 ConfPairs (org.xipki.common.ConfPairs)3 IssuerEntry (org.xipki.ocsp.api.IssuerEntry)3 Date (java.util.Date)2 DataSourceWrapper (org.xipki.datasource.DataSourceWrapper)2 OcspStoreException (org.xipki.ocsp.api.OcspStoreException)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Statement (java.sql.Statement)1