javax.sql.rowset.RowSetWarning Java Examples

The following examples show how to use javax.sql.rowset.RowSetWarning. 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: RowSetWarningTests.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test11() throws Exception {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning sqe = createSerializedException(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: SerialJavaObject.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * readObject is called to restore the state of the {@code SerialJavaObject}
 * from a stream.
 */
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {

    ObjectInputStream.GetField fields1 = s.readFields();
    @SuppressWarnings("unchecked")
    Vector<RowSetWarning> tmp = (Vector<RowSetWarning>)fields1.get("chain", null);
    if (tmp != null)
        chain = new Vector<>(tmp);

    obj = fields1.get("obj", null);
    if (obj != null) {
        fields = obj.getClass().getFields();
        if(hasStaticFields(fields))
            throw new IOException("Located static fields in " +
            "object instance. Cannot serialize");
    } else {
        throw new IOException("Object cannot be null!");
    }

}
 
Example #3
Source File: RowSetWarningTests.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test11() throws Exception {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning sqe = createSerializedException(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 #4
Source File: RowSetWarningTests.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned RowSetWarning is correct using
 * traditional while loop
 */
@Test
public void test09() {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning 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: RowSetWarningTests.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned RowSetWarning is correct using
 * traditional while loop
 */
@Test
public void test09() {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning 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: SerialJavaObject.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * readObject is called to restore the state of the {@code SerialJavaObject}
 * from a stream.
 */
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {

    ObjectInputStream.GetField fields1 = s.readFields();
    @SuppressWarnings("unchecked")
    Vector<RowSetWarning> tmp = (Vector<RowSetWarning>)fields1.get("chain", null);
    if (tmp != null)
        chain = new Vector<>(tmp);

    obj = fields1.get("obj", null);
    if (obj != null) {
        fields = obj.getClass().getFields();
        if(hasStaticFields(fields))
            throw new IOException("Located static fields in " +
            "object instance. Cannot serialize");
    } else {
        throw new IOException("Object cannot be null!");
    }

}
 
Example #7
Source File: SerialJavaObject.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * readObject is called to restore the state of the {@code SerialJavaObject}
 * from a stream.
 */
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {

    ObjectInputStream.GetField fields1 = s.readFields();
    @SuppressWarnings("unchecked")
    Vector<RowSetWarning> tmp = (Vector<RowSetWarning>)fields1.get("chain", null);
    if (tmp != null)
        chain = new Vector<>(tmp);

    obj = fields1.get("obj", null);
    if (obj != null) {
        fields = obj.getClass().getFields();
        if(hasStaticFields(fields))
            throw new IOException("Located static fields in " +
            "object instance. Cannot serialize");
    } else {
        throw new IOException("Object cannot be null!");
    }

}
 
Example #8
Source File: SerialJavaObject.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * readObject is called to restore the state of the {@code SerialJavaObject}
 * from a stream.
 */
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {

    ObjectInputStream.GetField fields1 = s.readFields();
    @SuppressWarnings("unchecked")
    Vector<RowSetWarning> tmp = (Vector<RowSetWarning>)fields1.get("chain", null);
    if (tmp != null)
        chain = new Vector<>(tmp);

    obj = fields1.get("obj", null);
    if (obj != null) {
        fields = obj.getClass().getFields();
        if(hasStaticFields(fields))
            throw new IOException("Located static fields in " +
            "object instance. Cannot serialize");
    } else {
        throw new IOException("Object cannot be null!");
    }

}
 
Example #9
Source File: RowSetWarningTests.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test07() {
    RowSetWarning ex = new RowSetWarning("Exception 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Exception 2");
    RowSetWarning ex2 = new RowSetWarning("Exception 3");
    ex2.initCause(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 #10
Source File: RowSetWarningTests.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned RowSetWarning is correct using
 * traditional while loop
 */
@Test
public void test09() {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning 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: SerialJavaObject.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * readObject is called to restore the state of the {@code SerialJavaObject}
 * from a stream.
 */
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {

    ObjectInputStream.GetField fields1 = s.readFields();
    @SuppressWarnings("unchecked")
    Vector<RowSetWarning> tmp = (Vector<RowSetWarning>)fields1.get("chain", null);
    if (tmp != null)
        chain = new Vector<>(tmp);

    obj = fields1.get("obj", null);
    if (obj != null) {
        fields = obj.getClass().getFields();
        if(hasStaticFields(fields))
            throw new IOException("Located static fields in " +
            "object instance. Cannot serialize");
    } else {
        throw new IOException("Object cannot be null!");
    }

}
 
Example #12
Source File: RowSetWarningTests.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test11() throws Exception {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning sqe = createSerializedException(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 #13
Source File: RowSetWarningTests.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 RowSetWarning is correct using
 * traditional while loop
 */
@Test
public void test09() {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning 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 #14
Source File: SerialJavaObject.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * readObject is called to restore the state of the {@code SerialJavaObject}
 * from a stream.
 */
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {

    ObjectInputStream.GetField fields1 = s.readFields();
    @SuppressWarnings("unchecked")
    Vector<RowSetWarning> tmp = (Vector<RowSetWarning>)fields1.get("chain", null);
    if (tmp != null)
        chain = new Vector<>(tmp);

    obj = fields1.get("obj", null);
    if (obj != null) {
        fields = obj.getClass().getFields();
        if(hasStaticFields(fields))
            throw new IOException("Located static fields in " +
            "object instance. Cannot serialize");
    } else {
        throw new IOException("Object cannot be null!");
    }

}
 
Example #15
Source File: RowSetWarningTests.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test07() {
    RowSetWarning ex = new RowSetWarning("Exception 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Exception 2");
    RowSetWarning ex2 = new RowSetWarning("Exception 3");
    ex2.initCause(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 #16
Source File: RowSetWarningTests.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test11() throws Exception {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning sqe = createSerializedException(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 #17
Source File: RowSetWarningTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test07() {
    RowSetWarning ex = new RowSetWarning("Exception 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Exception 2");
    RowSetWarning ex2 = new RowSetWarning("Exception 3");
    ex2.initCause(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 #18
Source File: RowSetWarningTests.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test11() throws Exception {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning sqe = createSerializedException(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 #19
Source File: RowSetWarningTests.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate that the ordering of the returned RowSetWarning is correct using
 * traditional while loop
 */
@Test
public void test09() {
    RowSetWarning ex = new RowSetWarning("Warning 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Warning 2");
    RowSetWarning ex2 = new RowSetWarning("Warning 3");
    ex2.initCause(t2);
    ex.setNextWarning(ex1);
    ex.setNextWarning(ex2);
    int num = 0;
    RowSetWarning 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 #20
Source File: SerialJavaObject.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * readObject is called to restore the state of the {@code SerialJavaObject}
 * from a stream.
 */
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {

    ObjectInputStream.GetField fields1 = s.readFields();
    @SuppressWarnings("unchecked")
    Vector<RowSetWarning> tmp = (Vector<RowSetWarning>)fields1.get("chain", null);
    if (tmp != null)
        chain = new Vector<>(tmp);

    obj = fields1.get("obj", null);
    if (obj != null) {
        fields = obj.getClass().getFields();
        if(hasStaticFields(fields))
            throw new IOException("Located static fields in " +
            "object instance. Cannot serialize");
    } else {
        throw new IOException("Object cannot be null!");
    }

}
 
Example #21
Source File: SerialJavaObject.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Registers the given warning.
 */
private void setWarning(RowSetWarning e) {
    if (chain == null) {
        chain = new Vector<>();
    }
    chain.add(e);
}
 
Example #22
Source File: RowSetWarningTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test04() {
    RowSetWarning ex = new RowSetWarning(reason, state, errorCode);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && ex.getCause() == null
            && ex.getErrorCode() == errorCode);
}
 
Example #23
Source File: RowSetWarningTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test10() throws Exception {
    RowSetWarning e = new RowSetWarning(reason, state, errorCode);
    RowSetWarning ex1 = createSerializedException(e);
    assertTrue(reason.equals(ex1.getMessage())
            && ex1.getSQLState().equals(state)
            && ex1.getCause() == null
            && ex1.getErrorCode() == errorCode);
}
 
Example #24
Source File: RowSetWarningTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test06() {
    RowSetWarning ex = new RowSetWarning("Exception 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Exception 2");
    RowSetWarning ex2 = new RowSetWarning("Exception 3");
    ex2.initCause(t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example #25
Source File: RowSetWarningTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test10() throws Exception {
    RowSetWarning e = new RowSetWarning(reason, state, errorCode);
    RowSetWarning ex1 = createSerializedException(e);
    assertTrue(reason.equals(ex1.getMessage())
            && ex1.getSQLState().equals(state)
            && ex1.getCause() == null
            && ex1.getErrorCode() == errorCode);
}
 
Example #26
Source File: RowSetWarningTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test02() {
    RowSetWarning ex = new RowSetWarning(reason);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}
 
Example #27
Source File: SerialJavaObject.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor for <code>SerialJavaObject</code> helper class.
 * <p>
 *
 * @param obj the Java <code>Object</code> to be serialized
 * @throws SerialException if the object is found not to be serializable
 */
public SerialJavaObject(Object obj) throws SerialException {

    // if any static fields are found, an exception
    // should be thrown


    // get Class. Object instance should always be available
    Class<?> c = obj.getClass();

    // determine if object implements Serializable i/f
    if (!(obj instanceof java.io.Serializable)) {
        setWarning(new RowSetWarning("Warning, the object passed to the constructor does not implement Serializable"));
    }

    // can only determine public fields (obviously). If
    // any of these are static, this should invalidate
    // the action of attempting to persist these fields
    // in a serialized form
    fields = c.getFields();

    if (hasStaticFields(fields)) {
        throw new SerialException("Located static fields in " +
            "object instance. Cannot serialize");
    }

    this.obj = obj;
}
 
Example #28
Source File: SerialJavaObject.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor for <code>SerialJavaObject</code> helper class.
 * <p>
 *
 * @param obj the Java <code>Object</code> to be serialized
 * @throws SerialException if the object is found not to be serializable
 */
public SerialJavaObject(Object obj) throws SerialException {

    // if any static fields are found, an exception
    // should be thrown


    // get Class. Object instance should always be available
    Class<?> c = obj.getClass();

    // determine if object implements Serializable i/f
    if (!(obj instanceof java.io.Serializable)) {
        setWarning(new RowSetWarning("Warning, the object passed to the constructor does not implement Serializable"));
    }

    // can only determine public fields (obviously). If
    // any of these are static, this should invalidate
    // the action of attempting to persist these fields
    // in a serialized form
    fields = c.getFields();

    if (hasStaticFields(fields)) {
        throw new SerialException("Located static fields in " +
            "object instance. Cannot serialize");
    }

    this.obj = obj;
}
 
Example #29
Source File: RowSetWarningTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test06() {
    RowSetWarning ex = new RowSetWarning("Exception 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Exception 2");
    RowSetWarning ex2 = new RowSetWarning("Exception 3");
    ex2.initCause(t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example #30
Source File: RowSetWarningTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test06() {
    RowSetWarning ex = new RowSetWarning("Exception 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Exception 2");
    RowSetWarning ex2 = new RowSetWarning("Exception 3");
    ex2.initCause(t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}