本文整理汇总了Java中javax.sql.rowset.RowSetWarning类的典型用法代码示例。如果您正苦于以下问题:Java RowSetWarning类的具体用法?Java RowSetWarning怎么用?Java RowSetWarning使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RowSetWarning类属于javax.sql.rowset包,在下文中一共展示了RowSetWarning类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readObject
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
/**
* 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!");
}
}
示例2: test07
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
@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();
}
}
示例3: test09
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
/**
* 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();
}
}
示例4: test11
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
@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();
}
}
示例5: testGetRowSetWarnings
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
public void testGetRowSetWarnings() throws Exception {
JdbcRowSet jrs = newJdbcRowSet();
jrs.setCommand("SELECT * FROM USER_INFO");
jrs.setUrl(DERBY_URL);
jrs.execute();
/*
* TODO not sure when and how will cause RowSetWarning
*/
assertNull(jrs.getRowSetWarnings());
jrs.close();
jrs = newJdbcRowSet();
RowSetWarning warning = jrs.getRowSetWarnings();
super.assertNull(warning);
// TODO Try to produce warnings.
jrs.close();
// Checks for Exception after closing jrs.
assertNull(rs.getWarnings());
assertNull(jrs.getRowSetWarnings());
}
示例6: SerialJavaObject
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
/**
* 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;
}
示例7: setWarning
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
/**
* Registers the given warning.
*/
private void setWarning(RowSetWarning e) {
if (chain == null) {
chain = new Vector<>();
}
chain.add(e);
}
示例8: test01
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
@Test
public void test01() {
RowSetWarning ex = new RowSetWarning();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
示例9: test02
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
@Test
public void test02() {
RowSetWarning ex = new RowSetWarning(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
示例10: test03
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
@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);
}
示例11: test04
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
@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);
}
示例12: test05
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
@Test
public void test05() throws Exception {
RowSetWarning e = new RowSetWarning(reason, state, errorCode);
e.initCause(t);
RowSetWarning ex1 = createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
示例13: test06
import javax.sql.rowset.RowSetWarning; //导入依赖的package包/类
@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()));
}
}