Java Code Examples for javax.sql.rowset.RowSetWarning

The following examples show how to use javax.sql.rowset.RowSetWarning. These examples are extracted from open source projects. 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
/**
 * 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 2
Source Project: jdk1.8-source-analysis   Source File: SerialJavaObject.java    License: 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
@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
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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 Project: jdk8u_jdk   Source File: SerialJavaObject.java    License: 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
@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
/**
 * 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
@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 12
Source Project: jdk8u60   Source File: SerialJavaObject.java    License: 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 13
@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 14
/**
 * 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 15
/**
 * 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 16
Source Project: jdk8u60   Source File: RowSetWarningTests.java    License: 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 17
Source Project: jdk8u-jdk   Source File: RowSetWarningTests.java    License: 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 18
@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 19
/**
 * 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 Project: hottub   Source File: RowSetWarningTests.java    License: 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 21
/**
 * 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 22
/**
 * Registers the given warning.
 */
private void setWarning(RowSetWarning e) {
    if (chain == null) {
        chain = new Vector<>();
    }
    chain.add(e);
}
 
Example 23
Source Project: jdk8u_jdk   Source File: SerialJavaObject.java    License: 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 24
Source Project: jdk8u-jdk   Source File: RowSetWarningTests.java    License: 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 25
@Test
public void test01() {
    RowSetWarning ex = new RowSetWarning();
    assertTrue(ex.getMessage() == null
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}
 
Example 26
@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
@Test
public void test03() {

    RowSetWarning ex = new RowSetWarning(reason, state);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}
 
Example 28
@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 29
@Test
public void test08() {
    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;
    for (Throwable e : ex) {
        assertTrue(warnings[num++].equals(e.getMessage()));
    }
}
 
Example 30
@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()));
    }
}