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

The following examples show how to use java.sql.SQLWarning#setNextWarning() . 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 jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned SQLWarning is correct using
 * traditional while loop
 */
@Test
public void test14() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    SQLWarning sqe = ex;
    while (sqe != null) {
        assertTrue(warnings[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextWarning();
    }
}
 
Example 2
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 SQLWarning is correct using
 * traditional while loop
 */
@Test
public void test14() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    SQLWarning sqe = ex;
    while (sqe != null) {
        assertTrue(warnings[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextWarning();
    }
}
 
Example 3
Source File: SingleHopResultSet.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public SQLWarning getWarnings() throws SQLException {
  SQLWarning allwarnings = null;
  for (int i=0; i<this.totalNumOfResults; i++) {
    SQLWarning warnings = this.prepStmntArray[i].getSuperResultSet().getWarnings();
    if (allwarnings != null) {
      SQLWarning warn = warnings.getNextWarning();
      while(warn != null) {
        allwarnings.setNextWarning(warn);
      }
    }
    else {
      allwarnings = warnings;
    }
  }
  return allwarnings;
}
 
Example 4
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 SQLWarning is correct using
 * traditional while loop
 */
@Test
public void test14() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    SQLWarning sqe = ex;
    while (sqe != null) {
        assertTrue(warnings[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextWarning();
    }
}
 
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 SQLWarning is correct using
 * traditional while loop
 */
@Test
public void test14() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    SQLWarning sqe = ex;
    while (sqe != null) {
        assertTrue(warnings[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextWarning();
    }
}
 
Example 6
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 SQLWarning is correct using
 * traditional while loop
 */
@Test
public void test14() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    SQLWarning sqe = ex;
    while (sqe != null) {
        assertTrue(warnings[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextWarning();
    }
}
 
Example 7
Source File: SQLWarningTests.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned SQLWarning is correct using
 * traditional while loop
 */
@Test
public void test14() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    SQLWarning sqe = ex;
    while (sqe != null) {
        assertTrue(warnings[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextWarning();
    }
}
 
Example 8
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 SQLWarning is correct using
 * traditional while loop
 */
@Test
public void test14() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    SQLWarning sqe = ex;
    while (sqe != null) {
        assertTrue(warnings[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextWarning();
    }
}
 
Example 9
Source File: BaseJdbcObject.java    From cassandra-jdbc-driver with Apache License 2.0 6 votes vote down vote up
/**
 * Append a warning to the end of chained SQL warnings.
 *
 * @param warning warning to be appended to the warnings list
 */
public void appendWarning(SQLWarning warning) {
    if (warning != null) {
        if (_warning == null) {
            _warning = warning;
        } else {
            SQLWarning w = _warning;
            SQLWarning prevWarning = w;
            do {
                if (w == warning) {
                    break;
                } else {
                    prevWarning = w;
                }
            } while ((w = w.getNextWarning()) != null);

            if (prevWarning != w) {
                prevWarning.setNextWarning(warning);
            }
        }
    }
}
 
Example 10
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 SQLWarning is correct using
 * traditional while loop
 */
@Test
public void test14() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    SQLWarning sqe = ex;
    while (sqe != null) {
        assertTrue(warnings[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextWarning();
    }
}
 
Example 11
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 SQLWarning is correct using
 * traditional while loop
 */
@Test
public void test14() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    SQLWarning sqe = ex;
    while (sqe != null) {
        assertTrue(warnings[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextWarning();
    }
}
 
Example 12
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 SQLWarning is correct using
 * for-each loop
 */
@Test
public void test13() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(warnings[num++].equals(e.getMessage()));
    }
}
 
Example 13
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 SQLWarning is correct using
 * for-each loop
 */
@Test
public void test13() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(warnings[num++].equals(e.getMessage()));
    }
}
 
Example 14
Source File: StandardException.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static SQLWarning newNoRowFoundWarning() {
  // this thread-local stuff is to avoid the brain-dead big sync
  // in DriverManager.println call from SQLWarning constructor
  SQLWarning sqlw = noRowFound.get();
  if (sqlw == null) {
    sqlw = newWarning(SQLState.LANG_NO_ROW_FOUND);
    noRowFound.set(sqlw);
  }
  else {
    sqlw.setNextWarning(null);
  }
  return sqlw;
}
 
Example 15
Source File: TestJdbcWarnings.java    From presto with Apache License 2.0 5 votes vote down vote up
private static SQLWarning fromPrestoWarnings(List<PrestoWarning> warnings)
{
    requireNonNull(warnings, "warnings is null");
    assertFalse(warnings.isEmpty());
    Iterator<PrestoWarning> iterator = warnings.iterator();
    PrestoSqlWarning first = toPrestoSqlWarning(iterator.next());
    SQLWarning current = first;
    while (iterator.hasNext()) {
        current.setNextWarning(toPrestoSqlWarning(iterator.next()));
        current = current.getNextWarning();
    }
    return first;
}
 
Example 16
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 SQLWarning is correct using
 * for-each loop
 */
@Test
public void test13() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(warnings[num++].equals(e.getMessage()));
    }
}
 
Example 17
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 SQLWarning is correct using
 * for-each loop
 */
@Test
public void test13() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(warnings[num++].equals(e.getMessage()));
    }
}
 
Example 18
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 SQLWarning is correct using
 * for-each loop
 */
@Test
public void test13() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(warnings[num++].equals(e.getMessage()));
    }
}
 
Example 19
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 SQLWarning is correct using
 * for-each loop
 */
@Test
public void test13() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(warnings[num++].equals(e.getMessage()));
    }
}
 
Example 20
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 SQLWarning is correct using
 * for-each loop
 */
@Test
public void test13() {
    SQLWarning ex = new SQLWarning("Warning 1", t1);
    SQLWarning ex1 = new SQLWarning("Warning 2");
    SQLWarning ex2 = new SQLWarning("Warning 3", t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(warnings[num++].equals(e.getMessage()));
    }
}