I'm writing a program, from a security point of view, that will catch an SQLException. I'm trying to purge all sensitive information.
catch(SQLException se){
se.printStackTrace();
}
Would writing it the above way reveal sensitive information? If so, what would be a secure way to write it?
You are revealing parts of your code, as line numbers and variable names will be printed.
The best way would be to just custom your own message. Another method can be something similar to the way IIS error messages are printed: show full stack trace if the request is from the server computer (debugging) but show a generic error for external requests.