Java Code Examples for java.sql.SQLWarning#setNextException()

The following examples show how to use java.sql.SQLWarning#setNextException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SQLWarningTests.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
Example 2
Source File: SQLWarningTests.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
Example 3
Source File: SQLWarningTests.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
Example 4
Source File: SQLWarningTests.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
Example 5
Source File: SQLWarningTests.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
Example 6
Source File: SQLWarningTests.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
Example 7
Source File: SQLWarningTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
Example 8
Source File: SQLWarningTests.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
Example 9
Source File: SQLWarningTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 10
Source File: SQLWarningTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 11
Source File: SQLWarningTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 12
Source File: SQLWarningTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 13
Source File: SQLWarningTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 14
Source File: SQLWarningTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 15
Source File: SqlWarning.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Get the java.sql.SQLWarning for this SqlWarning
 */
public SQLWarning getSQLWarning()
{
    if (wrappedException_ != null) {
        return (SQLWarning) wrappedException_;
    }

    SQLWarning sqlw = new SQLWarning(getMessage(), getSQLState(), 
        getErrorCode());

    sqlw.initCause(this);

    // Set up the nextException chain
    if ( nextWarning_ != null )
    {
        // The exception chain gets constructed automatically through 
        // the beautiful power of recursion
        //
        // We have to use the right method to convert the next exception
        // depending upon its type.  Luckily with all the other subclasses
        // of SQLException we don't have to make our own matching 
        // subclasses because 
        sqlw.setNextException(
            nextException_ instanceof SqlWarning ?
                ((SqlWarning)nextException_).getSQLWarning() :
                nextException_.getSQLException());
    }
    
    return sqlw;
    
}
 
Example 16
Source File: SQLWarningTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 17
Source File: SQLWarningTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 18
Source File: SQLWarningTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLWarning ex = new SQLWarning("Exception 1", t1);
    SQLWarning ex1 = new SQLWarning("Exception 2");
    SQLWarning ex2 = new SQLWarning("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 19
Source File: SqlWarning.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
     * Get the java.sql.SQLWarning for this SqlWarning
     */
// GemStone changes BEGIN
    public SQLWarning getSQLWarning(final Agent agent) {
        final String message;
        final String sqlState = getSQLState();
        final int errorCode = getErrorCode();
        // fetching exception should not change inUnitOfWork (#44311)
        Connection conn = null;
        boolean savedInUnitOfWork = false;
        if (agent != null) {
          if ((conn = agent.connection_) != null) {
            savedInUnitOfWork = conn.inUnitOfWork_;
          }
          message = getMessage() + " (SQLState=" + sqlState + ",Severity="
              + errorCode + ",Server=" + agent.getServerLocation() + ')';
        }
        else {
          message = getMessage();
        }
        SQLWarning sqlw = new SQLWarning(message, sqlState,
            errorCode);
    /* (original code)
    public SQLWarning getSQLWarning()
    {
        SQLWarning sqlw = new SQLWarning(getMessage(), getSQLState(), 
            getErrorCode());
    */
// GemStone changes END

        sqlw.initCause(this);

        // Set up the nextException chain
        if ( nextWarning_ != null )
        {
            // The exception chain gets constructed automatically through 
            // the beautiful power of recursion
            //
            // We have to use the right method to convert the next exception
            // depending upon its type.  Luckily with all the other subclasses
            // of SQLException we don't have to make our own matching 
            // subclasses because 
            sqlw.setNextException(
                nextException_ instanceof SqlWarning ?
                    ((SqlWarning)nextException_).getSQLWarning(null /* GemStoneAddition */) :
                    nextException_.getSQLException(null /* GemStoneAddition */));
        }
// GemStone changes BEGIN
        // restore inUnitOfWork
        if (conn != null) {
          conn.setInUnitOfWork(savedInUnitOfWork);
        }
// GemStone changes END
        
        return sqlw;
        
    }
 
Example 20
Source File: SqlWarning.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
     * Get the java.sql.SQLWarning for this SqlWarning
     */
// GemStone changes BEGIN
    public SQLWarning getSQLWarning(final Agent agent) {
        final String message;
        final String sqlState = getSQLState();
        final int errorCode = getErrorCode();
        // fetching exception should not change inUnitOfWork (#44311)
        Connection conn = null;
        boolean savedInUnitOfWork = false;
        if (agent != null) {
          if ((conn = agent.connection_) != null) {
            savedInUnitOfWork = conn.inUnitOfWork_;
          }
          message = getMessage() + " (SQLState=" + sqlState + ",Severity="
              + errorCode + ",Server=" + agent.getServerLocation() + ')';
        }
        else {
          message = getMessage();
        }
        SQLWarning sqlw = new SQLWarning(message, sqlState,
            errorCode);
    /* (original code)
    public SQLWarning getSQLWarning()
    {
        SQLWarning sqlw = new SQLWarning(getMessage(), getSQLState(), 
            getErrorCode());
    */
// GemStone changes END

        sqlw.initCause(this);

        // Set up the nextException chain
        if ( nextWarning_ != null )
        {
            // The exception chain gets constructed automatically through 
            // the beautiful power of recursion
            //
            // We have to use the right method to convert the next exception
            // depending upon its type.  Luckily with all the other subclasses
            // of SQLException we don't have to make our own matching 
            // subclasses because 
            sqlw.setNextException(
                nextException_ instanceof SqlWarning ?
                    ((SqlWarning)nextException_).getSQLWarning(null /* GemStoneAddition */) :
                    nextException_.getSQLException(null /* GemStoneAddition */));
        }
// GemStone changes BEGIN
        // restore inUnitOfWork
        if (conn != null) {
          conn.setInUnitOfWork(savedInUnitOfWork);
        }
// GemStone changes END
        
        return sqlw;
        
    }