Search in sources :

Example 6 with SQLWarning

use of java.sql.SQLWarning in project voltdb by VoltDB.

the class JDBCConnection method xlateRSType.

/**
     * Translates <code>ResultSet</code> type, adding to the warning
     * chain if the requested type is downgraded. <p>
     *
     * Up to and including HSQLDB 1.7.2,  <code>TYPE_FORWARD_ONLY</code> and
     * <code>TYPE_SCROLL_INSENSITIVE</code> are passed through. <p>
     *
     * Starting with 1.7.2, while <code>TYPE_SCROLL_SENSITIVE</code> is
     * downgraded to <code>TYPE_SCROLL_INSENSITIVE</code> and an SQLWarning is
     * issued. <p>
     *
     * @param type of <code>ResultSet</code>; one of
     *     <code>JDBCResultSet.TYPE_XXX</code>
     * @return the actual type that will be used
     * @throws SQLException if type is not one of the defined values
     */
int xlateRSType(int type) throws SQLException {
    SQLWarning w;
    String msg;
    switch(type) {
        case JDBCResultSet.TYPE_FORWARD_ONLY:
        case JDBCResultSet.TYPE_SCROLL_INSENSITIVE:
            {
                return type;
            }
        case JDBCResultSet.TYPE_SCROLL_SENSITIVE:
            {
                msg = "TYPE_SCROLL_SENSITIVE => TYPE_SCROLL_SENSITIVE";
                w = new SQLWarning(msg, "SOO10", ErrorCode.JDBC_INVALID_ARGUMENT);
                addWarning(w);
                return JDBCResultSet.TYPE_SCROLL_INSENSITIVE;
            }
        default:
            {
                msg = "ResultSet type: " + type;
                throw Util.invalidArgument(msg);
            }
    }
}
Also used : SQLWarning(java.sql.SQLWarning)

Example 7 with SQLWarning

use of java.sql.SQLWarning in project jdk8u_jdk by JetBrains.

the class SQLWarningTests method test9.

/**
     * Create SQLWarning with Throwable
     */
@Test
public void test9() {
    SQLWarning ex = new SQLWarning(t);
    assertTrue(ex.getMessage().equals(cause) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0);
}
Also used : SQLWarning(java.sql.SQLWarning) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 8 with SQLWarning

use of java.sql.SQLWarning in project jdk8u_jdk by JetBrains.

the class SQLWarningTests method test10.

/**
     * Serialize a SQLWarning and make sure you can read it back properly
     */
@Test
public void test10() throws Exception {
    SQLWarning e = new SQLWarning(reason, state, errorCode, t);
    SQLWarning ex1 = createSerializedException(e);
    assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) && ex1.getErrorCode() == errorCode);
}
Also used : SQLWarning(java.sql.SQLWarning) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 9 with SQLWarning

use of java.sql.SQLWarning in project jdk8u_jdk by JetBrains.

the class SQLWarningTests method test1.

/**
     * Create SQLWarning with no-arg constructor
     */
@Test
public void test1() {
    SQLWarning ex = new SQLWarning();
    assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0);
}
Also used : SQLWarning(java.sql.SQLWarning) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 10 with SQLWarning

use of java.sql.SQLWarning in project jdk8u_jdk by JetBrains.

the class SQLWarningTests method test8.

/**
     * Create SQLWarning with null Throwable
     */
@Test
public void test8() {
    SQLWarning ex = new SQLWarning((Throwable) null);
    assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0);
}
Also used : SQLWarning(java.sql.SQLWarning) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Aggregations

SQLWarning (java.sql.SQLWarning)147 SQLException (java.sql.SQLException)47 Statement (java.sql.Statement)35 PreparedStatement (java.sql.PreparedStatement)30 Connection (java.sql.Connection)24 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 HashSet (java.util.HashSet)3 Properties (java.util.Properties)3 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)3