本文整理了Java中java.sql.SQLException.setStackTrace()
方法的一些代码示例,展示了SQLException.setStackTrace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SQLException.setStackTrace()
方法的具体详情如下:
包路径:java.sql.SQLException
类名称:SQLException
方法名:setStackTrace
暂无
代码示例来源:origin: org.astrogrid/astrogrid-dsa
/**
* Gets a database connection using the given credentials.
* This connection uses the configured URL to find the database and the
* configured JDBC driver.
*
* @param userName The user name as known to the DBMS.
* @param password The password as known to the DBMS.
*/
public Connection getConnection(String userName, String password) throws SQLException {
log.debug("Creating JDBC Connection from DriverManager, to Url "+jdbcUrl+" ("+userName+")");
try {
return DriverManager.getConnection(jdbcUrl, userName, password);
}
catch (SQLException se) {
//add more info to the sql exception. Especially the URL, as it is often a mistyped URL that gives 'no suitable driver'
SQLException newSe = new SQLException(se.getMessage()+" ["+se.getErrorCode()+"], connecting to "+jdbcUrl,
se.getSQLState(), se.getErrorCode());
newSe.setStackTrace(se.getStackTrace());
throw newSe;
}
}
代码示例来源:origin: org.astrogrid/astrogrid-dsa
/**
* Gets a database connection using the configured credentials.
* This connection uses the configured URL to find the database and the
* configured JDBC driver.
*
* @param userName The user name as known to the DBMS.
* @param password The password as known to the DBMS.
*/
public Connection getConnection() throws SQLException {
log.debug("Creating JDBC Connection from DriverManager, to Url "+jdbcUrl);
try {
if (userId != null) {
return DriverManager.getConnection(jdbcUrl, userId, password);
}
else {
return DriverManager.getConnection(jdbcUrl);
}
}
catch (SQLException se) {
//add more info to the sql exception. Especially the URL, as it is often a mistyped URL that gives 'no suitable driver'
SQLException newSe = new SQLException(se.getMessage()+" ["+se.getErrorCode()+"], connecting to "+jdbcUrl,
se.getSQLState(), se.getErrorCode());
newSe.setStackTrace(se.getStackTrace());
throw newSe;
}
}
代码示例来源:origin: org.onap.ccsdk.sli.core/dblib-provider
} else {
SQLException exception = new DBLibException(lastException.getMessage());
exception.setStackTrace(lastException.getStackTrace());
if(lastException.getCause() instanceof SQLException) {
throw (SQLException)lastException.getCause();
代码示例来源:origin: org.onap.ccsdk.sli.core/dblib-provider
} else {
SQLException exception = new DBLibException(lastException.getMessage());
exception.setStackTrace(lastException.getStackTrace());
if(lastException.getCause() instanceof SQLException) {
代码示例来源:origin: io.snappydata/gemfirexd-shared
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;
}
代码示例来源:origin: io.snappydata/snappydata-store-shared
se.getServerInfo());
sqle.setStackTrace(se.getStackTrace());
代码示例来源:origin: io.snappydata/gemfirexd-core
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
}
代码示例来源:origin: io.snappydata/gemfirexd
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
}
代码示例来源:origin: io.snappydata/snappydata-store-core
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
}
内容来源于网络,如有侵权,请联系作者删除!