Since the deprecation of the JDBC Bridge in Java, I've been making use of UCanAccess for JDBC connections. However UCanAccess does not throw exceptions in the form of normal try-catches, but immediately prints error lines to the console. As my users will not be accessing the software through the console, I would like to redirect all my console outputs to a JOptionPane message dialog, in order for my users to see error prints instead of it simply going to waste in the non-visible console. Is this possible? I have tried System.setErr
, but I can only get to override the write() method, outputting only a int?

- 54,432
- 29
- 203
- 199

- 307
- 2
- 16
-
2Take a look at http://stackoverflow.com/questions/3228427/redirect-system-out-println and http://stackoverflow.com/questions/12945537/how-to-set-output-stream-to-textarea – antonio Mar 03 '15 at 11:15
-
Thank you, http://stackoverflow.com/questions/12945537/how-to-set-output-stream-to-textarea proved to be very helpful. – anitag95 Mar 03 '15 at 11:25
1 Answers
UCanAccess throws exceptions in "the normal form", so your question is a bit misleading and your assumptions are wrong.
Also it uses SQLWarning while loading the db, see the jdbc interface about it (e.g. if it can't load a query). The UCanAccess console just prints them.
At Last, in the case of database corruption, data integrity problems or other very high severity problems jackcess or ucanaccess may print on the System.err. Obviously it may happen just if they are not blocking despite the severity. It's just to be sure that error message is logged without blocking a succesful db loading with an Exception(so I can't use a SQLWarning for them ).
For those specific issues you can redirect the System.err messages to a JOptionPane, but they are often very technical errors about mdb/accdb format, so I think it isn't a good idea show them in a user interface.
To re-direct the system.err in a specific error file instead(for subsequent problem solving) is much better.

- 1,700
- 9
- 8
-
Thank you for the great help on UCanAccess, however I would still like to, for debugging purposes in my admin programs, have a way to print those System.err messages to a JOptionPane. Any recommendations on how to do that? [This page](http://stackoverflow.com/questions/12945537/how-to-set-output-stream-to-textarea) gave some very good answers, but none that don't require me to have a seperate textarea. – anitag95 Mar 04 '15 at 19:29