Search in sources :

Example 11 with PalantirSqlException

use of com.palantir.exception.PalantirSqlException in project atlasdb by palantir.

the class BasicSQL method wrapPreparedStatement.

private <T> T wrapPreparedStatement(final Connection c, final FinalSQLString query, final Object[] vs, PreparedStatementVisitor<T> visitor, String description, AutoClose autoClose) throws PalantirSqlException, PalantirInterruptedException {
    SqlTimer.Handle timerKey = getSqlTimer().start(description, query.getKey(), query.getQuery());
    PreparedStatement ps = null;
    try {
        ps = BasicSQLUtils.runUninterruptably(() -> createPreparedStatement(c, query.getQuery(), vs), "SQL createPreparedStatement", c);
        return visitor.visit(ps);
    } catch (PalantirSqlException sqle) {
        throw wrapSQLExceptionWithVerboseLogging(sqle, query.getQuery(), vs);
    } finally {
        closeSilently(ps, autoClose);
        timerKey.stop();
    }
}
Also used : SqlTimer(com.palantir.nexus.db.monitoring.timer.SqlTimer) PreparedStatement(java.sql.PreparedStatement) PalantirSqlException(com.palantir.exception.PalantirSqlException)

Aggregations

PalantirSqlException (com.palantir.exception.PalantirSqlException)11 SQLException (java.sql.SQLException)6 PalantirInterruptedException (com.palantir.exception.PalantirInterruptedException)4 VerboseSQLException (com.palantir.util.sql.VerboseSQLException)4 IOException (java.io.IOException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 PreparedStatement (java.sql.PreparedStatement)4 ExecutionException (java.util.concurrent.ExecutionException)4 Cell (com.palantir.atlasdb.keyvalue.api.Cell)3 BlobHandler (com.palantir.db.oracle.JdbcHandler.BlobHandler)3 SqlTimer (com.palantir.nexus.db.monitoring.timer.SqlTimer)3 KeyAlreadyExistsException (com.palantir.atlasdb.keyvalue.api.KeyAlreadyExistsException)2 FinalSQLString (com.palantir.nexus.db.sql.BasicSQLString.FinalSQLString)2 SqlConnection (com.palantir.nexus.db.sql.SqlConnection)2 Map (java.util.Map)2 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 Throwables (com.palantir.common.base.Throwables)1 NamedThreadFactory (com.palantir.common.concurrent.NamedThreadFactory)1 PTExecutors (com.palantir.common.concurrent.PTExecutors)1