You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2014/03/04 09:33:00 UTC
svn commit: r1573934 - in
/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc:
EmbedConnection.java EmbedResultSet.java TransactionResourceImpl.java
Util.java
Author: kahatlen
Date: Tue Mar 4 08:32:59 2014
New Revision: 1573934
URL: http://svn.apache.org/r1573934
Log:
DERBY-6488: Get rid of the EmbedSQLException class
Remove the newEmbedSQLException methods, since they don't produce
EmbedSQLExceptions anymore, and use the SQLExceptionFactory methods
instead.
Add a Throwable parameter to seeNextException() so that the root cause
will be shown when printStackTrace() is called on the top-level
exception.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=1573934&r1=1573933&r2=1573934&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Tue Mar 4 08:32:59 2014
@@ -2645,8 +2645,7 @@ public class EmbedConnection implements
} catch (StandardException mse) {
throw Util.seeNextException(SQLState.CREATE_DATABASE_FAILED,
- new Object[] { dbname },
- handleException(mse));
+ handleException(mse), mse, dbname);
}
// clear these values as some modules hang onto
@@ -2840,8 +2839,8 @@ public class EmbedConnection implements
nse = Util.generateCsSQLException(mse);
throw Util.seeNextException(SQLState.BOOT_DATABASE_FAILED,
- new Object[] { dbname,
- (Object) this.getClass().getClassLoader() }, nse);
+ nse, (ne == null ? mse : ne),
+ dbname, getClass().getClassLoader());
}
// If database exists, getDatabase() will return the database object.
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=1573934&r1=1573933&r2=1573934&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Tue Mar 4 08:32:59 2014
@@ -4784,12 +4784,8 @@ public class EmbedResultSet extends Conn
private void checkScrollCursor(String methodName) throws SQLException {
checkIfClosed(methodName);
if (stmt.getResultSetType() == java.sql.ResultSet.TYPE_FORWARD_ONLY)
- throw Util
- .newEmbedSQLException(
- SQLState.NOT_ON_FORWARD_ONLY_CURSOR,
- new Object[] { methodName },
- StandardException
- .getSeverityFromIdentifier(SQLState.NOT_ON_FORWARD_ONLY_CURSOR));
+ throw Util.generateCsSQLException(
+ SQLState.NOT_ON_FORWARD_ONLY_CURSOR, methodName);
}
private void checkUpdatableCursor(String operation) throws SQLException {
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java?rev=1573934&r1=1573933&r2=1573934&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java Tue Mar 4 08:32:59 2014
@@ -429,7 +429,8 @@ public final class TransactionResourceIm
// chain. Therefore, call wrapInSQLException() recursively to
// convert the cause chain into a chain of SQLExceptions.
return Util.seeNextException(se.getMessageId(),
- se.getArguments(), wrapInSQLException(se.getCause()));
+ wrapInSQLException(se.getCause()), se.getCause(),
+ se.getArguments());
}
// thrownException is a Java exception
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java?rev=1573934&r1=1573933&r2=1573934&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java Tue Mar 4 08:32:59 2014
@@ -124,35 +124,6 @@ public abstract class Util {
errorStringBuilder.reset();
}
-
- /**
- * This looks up the message and sqlstate values and calls
- * the SQLExceptionFactory method to generate
- * the appropriate exception off of them.
- */
-
- private static SQLException newEmbedSQLException(String messageId,
- Object[] args, SQLException next, int severity, Throwable t) {
- String message = MessageService.getTextMessage(messageId, args);
- return ExceptionFactory.getInstance().getSQLException(
- message, messageId, next, severity, t, args);
- }
-
- public static SQLException newEmbedSQLException(String messageId,
- Object[] args, int severity) {
- return newEmbedSQLException(messageId, args, (SQLException) null, severity, (Throwable) null);
- }
-
- private static SQLException newEmbedSQLException(String messageId,
- Object[] args, int severity, Throwable t) {
- return newEmbedSQLException(messageId,args, (SQLException) null, severity, t);
- }
-
- private static SQLException newEmbedSQLException(
- String messageId, int severity) {
- return newEmbedSQLException(messageId, (Object[]) null, (SQLException) null, severity, (Throwable) null);
- }
-
// class interface
@@ -243,22 +214,19 @@ public abstract class Util {
** Its parameters are specific to its message.
** These will throw SQLException when the message repository
** cannot be located.
- ** Note that these methods call the static method newEmbedSQLException,
+ ** Note that these methods use the SQL exception factory,
** they don't directly do a new Util.
*/
public static SQLException generateCsSQLException(
String error, Object... args) {
- return newEmbedSQLException(error,
- args,
- StandardException.getSeverityFromIdentifier(error));
+ return generateCsSQLException(error, null, args);
}
static SQLException generateCsSQLException(
String error, Throwable t, Object... args) {
- return newEmbedSQLException(error,
- args,
- StandardException.getSeverityFromIdentifier(error), t);
+ return ExceptionFactory.getInstance().getSQLException(
+ error, (SQLException) null, t, args);
}
public static SQLException generateCsSQLException(StandardException se) {
@@ -268,8 +236,7 @@ public abstract class Util {
}
public static SQLException noCurrentConnection() {
- return newEmbedSQLException(SQLState.NO_CURRENT_CONNECTION,
- StandardException.getSeverityFromIdentifier(SQLState.NO_CURRENT_CONNECTION));
+ return generateCsSQLException(SQLState.NO_CURRENT_CONNECTION);
}
/**
@@ -278,14 +245,15 @@ public abstract class Util {
* <code>setNextException()</code>.
*
* @param messageId message id
+ * @param next the next SQLException, possibly null
+ * @param cause the underlying exception, possibly null
* @param args the arguments to the message creation
- * @param next the next SQLException
* @return an SQLException wrapping another SQLException
*/
- static SQLException seeNextException(String messageId, Object[] args,
- SQLException next) {
- return newEmbedSQLException(messageId, args, next,
- StandardException.getSeverityFromIdentifier(messageId), null);
+ static SQLException seeNextException(String messageId, SQLException next,
+ Throwable cause, Object... args) {
+ return ExceptionFactory.getInstance().getSQLException(
+ messageId, next, cause, args);
}
public static SQLException javaException(Throwable t) {
@@ -305,9 +273,9 @@ public abstract class Util {
next = javaException(cause);
}
}
- SQLException result = newEmbedSQLException(SQLState.JAVA_EXCEPTION,
- new Object[] {name, msg}, next,
- ExceptionSeverity.NO_APPLICABLE_SEVERITY, t);
+
+ SQLException result = seeNextException(
+ SQLState.JAVA_EXCEPTION, next, t, name, msg);
if ( result.getErrorCode() >= logSeverityLevel ) { logSQLException( result ); }
@@ -316,8 +284,8 @@ public abstract class Util {
public static SQLException policyNotReloaded( Throwable t ) {
- return newEmbedSQLException(SQLState.POLICY_NOT_RELOADED, new Object[] { t.getMessage() },
- StandardException.getSeverityFromIdentifier(SQLState.POLICY_NOT_RELOADED), t);
+ return generateCsSQLException(
+ SQLState.POLICY_NOT_RELOADED, t, t.getMessage());
}
public static SQLException notImplemented() {
@@ -326,10 +294,7 @@ public abstract class Util {
}
public static SQLException notImplemented(String feature) {
-
- return newEmbedSQLException(SQLState.NOT_IMPLEMENTED,
- new Object[] {feature},
- StandardException.getSeverityFromIdentifier(SQLState.NOT_IMPLEMENTED));
+ return generateCsSQLException(SQLState.NOT_IMPLEMENTED, feature);
}
static SQLException setStreamFailure(IOException e) {
@@ -342,9 +307,8 @@ public abstract class Util {
}
static SQLException typeMisMatch(int targetSQLType) {
- return newEmbedSQLException(SQLState.TYPE_MISMATCH,
- new Object[] {typeName(targetSQLType)},
- StandardException.getSeverityFromIdentifier(SQLState.TYPE_MISMATCH));
+ return generateCsSQLException(
+ SQLState.TYPE_MISMATCH, typeName(targetSQLType));
}
/** Create the correct BatchUpdateException depending on whether this is Java 8 or lower */