Link to home
Start Free TrialLog in
Avatar of allelopath
allelopath

asked on

override printstacktrace

I am getting an exception in when running my program in eclipse. The entire trace is not shown. It displays some of the lines, but then is stays "and 12 more lines"
mtamonkey said that this issue was reported as a BUG to sun.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4775147
It's not something that they'll FIX, but they do list the customer's workaround which was to override the printstacktrace function.

The exception class is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
I should create my own CommunicationsException?

package com.mycompany.exceptions;

public class CommunicationsException {

public void printStackTrace(PrintWriter s) {
  // what goes here?
}
 
}
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of allelopath
allelopath

ASKER

I'm not following you... i have this:

try {
    connection = DriverManager.getConnection(url, user, password);
    statement = connection.createStatement();
} catch (SQLException e) {
     e.printStackTrace();
     System.exit(-1);
}

What do I do?
Instead of

>> e.printStackTrace();

Try

for (StackTraceElement ste : e.getStackTrace()) {
      System.err.println(e);
}      
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, but there's no good reason to create a List from the StackTraceElement[]
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:-)