下面列出了java.sql.SQLWarning#setNextException ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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()));
}
}
/**
* 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()));
}
}
/**
* 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()));
}
}
/**
* 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()));
}
}
/**
* 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;
}
/**
* 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()));
}
}
/**
* 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()));
}
}
/**
* 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()));
}
}
/**
* 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()));
}
}
/**
* 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()));
}
}
/**
* 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;
}
/**
* 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;
}