下面列出了java.sql.SQLException#setStackTrace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static SQLException appendMessageToException(SQLException sqlEx, String messageToAppend, ExceptionInterceptor interceptor) {
String sqlState = sqlEx.getSQLState();
int vendorErrorCode = sqlEx.getErrorCode();
SQLException sqlExceptionWithNewMessage = SQLError.createSQLException(sqlEx.getMessage() + messageToAppend, sqlState, vendorErrorCode, interceptor);
sqlExceptionWithNewMessage.setStackTrace(sqlEx.getStackTrace());
return sqlExceptionWithNewMessage;
}
public static SQLException newSQLException(GFXDException gfxde) {
GFXDExceptionData payload = gfxde.getExceptionData();
SQLException sqle = newSQLException(payload, gfxde.getCause(),
gfxde.getServerInfo());
// since GFXDException is always a wrapper, no need to record the stack
sqle.setStackTrace(gfxde.getStackTrace());
// build next exceptions
List<GFXDExceptionData> nextList = gfxde.getNextExceptions();
SQLException current = sqle, next;
if (nextList != null) {
for (GFXDExceptionData nextData : nextList) {
// check for server stack indicator
if (SQLState.GFXD_SERVER_STACK_INDICATOR.equals(
nextData.getSqlState())) {
Throwable cause = sqle;
while (cause.getCause() != null) {
cause = cause.getCause();
}
cause.initCause(new ServerException(nextData.getReason()));
}
else {
next = newSQLException(nextData, null, null);
current.setNextException(next);
current = next;
}
}
}
return sqle;
}
public static SQLException generateCsSQLException(StandardException se) {
// GemStone changes BEGIN
// unwrap the StandardException to reduce stack depth (#42595)
// also change all StandardExceptions in the chain to SQLException
Throwable cause = se.getCause();
DerbyIOException dioe;
if (cause instanceof StandardException) {
cause = generateCsSQLException((StandardException)cause);
}
else if (cause instanceof DerbyIOException
&& (dioe = (DerbyIOException)cause).getSQLState() != null) {
cause = exceptionFactory.getSQLException(dioe.getMessage(),
dioe.getSQLState(), null, StandardException
.getSeverityFromIdentifier(dioe.getSQLState()),
cause.getCause(), null);
}
final SQLException sqle = exceptionFactory.getSQLException(
se.getMessage(), se.getMessageId(), null,
se.getSeverity(), cause, se.getArguments());
// copy stack from original exception
sqle.setStackTrace(se.getStackTrace());
return sqle;
/* (original code)
return exceptionFactory.getSQLException(
se.getMessage(), se.getMessageId(), (SQLException) null,
se.getSeverity(), se, se.getArguments());
*/
// GemStone changes END
}
private static SQLException appendMessageToException(SQLException sqlEx, String messageToAppend, ExceptionInterceptor interceptor) {
String sqlState = sqlEx.getSQLState();
int vendorErrorCode = sqlEx.getErrorCode();
SQLException sqlExceptionWithNewMessage = SQLError.createSQLException(sqlEx.getMessage() + messageToAppend, sqlState, vendorErrorCode, interceptor);
sqlExceptionWithNewMessage.setStackTrace(sqlEx.getStackTrace());
return sqlExceptionWithNewMessage;
}
public static SQLException newSQLException(GFXDException gfxde) {
GFXDExceptionData payload = gfxde.getExceptionData();
SQLException sqle = newSQLException(payload, gfxde.getCause(),
gfxde.getServerInfo());
// since GFXDException is always a wrapper, no need to record the stack
sqle.setStackTrace(gfxde.getStackTrace());
// build next exceptions
List<GFXDExceptionData> nextList = gfxde.getNextExceptions();
SQLException current = sqle, next;
if (nextList != null) {
for (GFXDExceptionData nextData : nextList) {
// check for server stack indicator
if (SQLState.GFXD_SERVER_STACK_INDICATOR.equals(
nextData.getSqlState())) {
Throwable cause = sqle;
while (cause.getCause() != null) {
cause = cause.getCause();
}
cause.initCause(new ServerException(nextData.getReason()));
}
else {
next = newSQLException(nextData, null, null);
current.setNextException(next);
current = next;
}
}
}
return sqle;
}
public static SQLException generateCsSQLException(StandardException se) {
// GemStone changes BEGIN
// unwrap the StandardException to reduce stack depth (#42595)
// also change all StandardExceptions in the chain to SQLException
Throwable cause = se.getCause();
DerbyIOException dioe;
if (cause instanceof StandardException) {
cause = generateCsSQLException((StandardException)cause);
}
else if (cause instanceof DerbyIOException
&& (dioe = (DerbyIOException)cause).getSQLState() != null) {
cause = exceptionFactory.getSQLException(dioe.getMessage(),
dioe.getSQLState(), null, StandardException
.getSeverityFromIdentifier(dioe.getSQLState()),
cause.getCause(), null);
}
final SQLException sqle = exceptionFactory.getSQLException(
se.getMessage(), se.getMessageId(), null,
se.getSeverity(), cause, se.getArguments());
// copy stack from original exception
sqle.setStackTrace(se.getStackTrace());
return sqle;
/* (original code)
return exceptionFactory.getSQLException(
se.getMessage(), se.getMessageId(), (SQLException) null,
se.getSeverity(), se, se.getArguments());
*/
// GemStone changes END
}