You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ni...@apache.org on 2009/11/29 01:10:52 UTC
svn commit: r885179 -
/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/SQLNestedException.java
Author: niallp
Date: Sun Nov 29 00:10:52 2009
New Revision: 885179
URL: http://svn.apache.org/viewvc?rev=885179&view=rev
Log:
DBCP-310 Simplify SQLNestedException now minimum is JDK 1.4
Modified:
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/SQLNestedException.java
Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/SQLNestedException.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/SQLNestedException.java?rev=885179&r1=885178&r2=885179&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/SQLNestedException.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/SQLNestedException.java Sun Nov 29 00:10:52 2009
@@ -28,34 +28,12 @@
*
* @author Dirk Verbeeck
* @version $Revision$ $Date$
- * @deprecated Use '(SQLException) new SQLException(msg).initCause(e)' instead; this class will be removed in DBCP 1.4
+ * @deprecated Use '(SQLException) new SQLException(msg).initCause(e)' instead; this class will be removed in DBCP 2.0
*/
public class SQLNestedException extends SQLException {
private static final long serialVersionUID = 1046151479543081202L;
- /* Throwable.getCause detection as found in commons-lang */
- private static final Method THROWABLE_CAUSE_METHOD;
- static {
- Method getCauseMethod;
- try {
- getCauseMethod = Throwable.class.getMethod("getCause", (Class[]) null);
- } catch (Exception e) {
- getCauseMethod = null;
- }
- THROWABLE_CAUSE_METHOD = getCauseMethod;
- }
-
- private static boolean hasThrowableCauseMethod() {
- return THROWABLE_CAUSE_METHOD != null;
- }
-
- /**
- * Holds the reference to the exception or error that caused
- * this exception to be thrown.
- */
- private final Throwable cause;
-
/**
* Constructs a new <code>SQLNestedException</code> with specified
* detail message and nested <code>Throwable</code>.
@@ -66,33 +44,8 @@
*/
public SQLNestedException(String msg, Throwable cause) {
super(msg);
- this.cause = cause;
if (cause != null){
- final PrintWriter logWriter = DriverManager.getLogWriter();
- if (logWriter != null) {
- logWriter.print("Caused by: ");
- cause.printStackTrace(logWriter);
- }
- }
- }
-
- public Throwable getCause() {
- return this.cause;
- }
-
- public void printStackTrace(PrintStream s) {
- super.printStackTrace(s);
- if ((cause != null) && !hasThrowableCauseMethod()) {
- s.print("Caused by: ");
- this.cause.printStackTrace(s);
- }
- }
-
- public void printStackTrace(PrintWriter s) {
- super.printStackTrace(s);
- if ((cause != null) && !hasThrowableCauseMethod()) {
- s.print("Caused by: ");
- this.cause.printStackTrace(s);
+ initCause(cause);
}
}
}