/** * 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; } }
/** * 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; } }
} else { SQLException exception = new DBLibException(lastException.getMessage()); exception.setStackTrace(lastException.getStackTrace()); if(lastException.getCause() instanceof SQLException) { throw (SQLException)lastException.getCause();
} else { SQLException exception = new DBLibException(lastException.getMessage()); exception.setStackTrace(lastException.getStackTrace()); if(lastException.getCause() instanceof SQLException) {
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; }
se.getServerInfo()); sqle.setStackTrace(se.getStackTrace());
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 }
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 }
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 }