Search in sources :

Example 51 with SQLWarning

use of java.sql.SQLWarning in project jaybird by FirebirdSQL.

the class AbstractWireOperations method processResponseWarnings.

/**
 * Checks if the response included a warning and signals that warning to the
 * WarningMessageCallback.
 *
 * @param response
 *         Response to process
 */
public final void processResponseWarnings(final Response response, WarningMessageCallback warningCallback) {
    if (warningCallback == null) {
        warningCallback = defaultWarningMessageCallback;
    }
    if (response instanceof GenericResponse) {
        GenericResponse genericResponse = (GenericResponse) response;
        @SuppressWarnings("ThrowableResultOfMethodCallIgnored") SQLException exception = genericResponse.getException();
        if (exception != null && exception instanceof SQLWarning) {
            warningCallback.processWarning((SQLWarning) exception);
        }
    }
}
Also used : SQLWarning(java.sql.SQLWarning) SQLException(java.sql.SQLException)

Example 52 with SQLWarning

use of java.sql.SQLWarning in project jaybird by FirebirdSQL.

the class OOConnection method setHoldability.

@Override
public void setHoldability(int holdability) {
    if (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT)
        return;
    final String message = "Holdability not modified. OpenOffice/LibreOffice compatibility always uses HOLD_CURSORS_OVER_COMMIT";
    log.debug(message);
    addWarning(new SQLWarning(message));
}
Also used : SQLWarning(java.sql.SQLWarning)

Example 53 with SQLWarning

use of java.sql.SQLWarning in project presto by prestodb.

the class TestJdbcWarnings method testStatementWarnings.

@Test
public void testStatementWarnings() throws SQLException {
    assertFalse(statement.execute("CREATE SCHEMA blackhole.test_schema"));
    SQLWarning warning = statement.getWarnings();
    assertNotNull(warning);
    TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(PRELOADED_WARNINGS);
    TestingWarningCollector warningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig);
    List<PrestoWarning> expectedWarnings = warningCollector.getWarnings();
    assertStartsWithExpectedWarnings(warning, fromPrestoWarnings(expectedWarnings));
    statement.clearWarnings();
    assertNull(statement.getWarnings());
}
Also used : SQLWarning(java.sql.SQLWarning) TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) WarningCollectorConfig(com.facebook.presto.execution.warnings.WarningCollectorConfig) TestingWarningCollectorConfig(com.facebook.presto.testing.TestingWarningCollectorConfig) PrestoWarning(com.facebook.presto.spi.PrestoWarning) TestingWarningCollector(com.facebook.presto.testing.TestingWarningCollector) Test(org.testng.annotations.Test)

Example 54 with SQLWarning

use of java.sql.SQLWarning in project presto by prestodb.

the class TestJdbcWarnings method fromPrestoWarnings.

private static SQLWarning fromPrestoWarnings(List<PrestoWarning> warnings) {
    requireNonNull(warnings, "warnings is null");
    assertFalse(warnings.isEmpty());
    Iterator<PrestoWarning> iterator = warnings.iterator();
    PrestoSqlWarning first = new PrestoSqlWarning(iterator.next());
    SQLWarning current = first;
    while (iterator.hasNext()) {
        current.setNextWarning(new PrestoSqlWarning(iterator.next()));
        current = current.getNextWarning();
    }
    return first;
}
Also used : SQLWarning(java.sql.SQLWarning) PrestoWarning(com.facebook.presto.spi.PrestoWarning)

Example 55 with SQLWarning

use of java.sql.SQLWarning in project killbill by killbill.

the class EntitySqlDaoWrapperInvocationHandler method printSQLWarnings.

private void printSQLWarnings() {
    if (logger.isDebugEnabled()) {
        try {
            SQLWarning warning = handle.getConnection().getWarnings();
            while (warning != null) {
                logger.debug("[SQL WARNING] {}", warning);
                warning = warning.getNextWarning();
            }
            handle.getConnection().clearWarnings();
        } catch (final SQLException e) {
            logger.debug("Error whilst retrieving SQL warnings", e);
        }
    }
}
Also used : SQLWarning(java.sql.SQLWarning) SQLException(java.sql.SQLException)

Aggregations

SQLWarning (java.sql.SQLWarning)153 SQLException (java.sql.SQLException)49 Statement (java.sql.Statement)37 PreparedStatement (java.sql.PreparedStatement)30 Connection (java.sql.Connection)26 ResultSet (java.sql.ResultSet)23 Test (org.testng.annotations.Test)19 Test (org.junit.Test)17 BaseTest (util.BaseTest)15 CallableStatement (java.sql.CallableStatement)13 ArrayList (java.util.ArrayList)9 JDBCStatement (org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement)8 ResultSetMetaData (java.sql.ResultSetMetaData)6 Expectations (org.jmock.Expectations)6 IOException (java.io.IOException)4 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)3 PrestoWarning (com.facebook.presto.spi.PrestoWarning)3 Properties (java.util.Properties)3 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)3 StatementContext (org.apache.derby.iapi.sql.conn.StatementContext)3