How to catch SQLException of Data? (eg. Data not exist)?

This is not really an easy thing to do and the solution will depend a lot on the vendor of the SQL connection (ie, mySQL, oracle, etc).

... try { ... } catch (SQLException e){ if (e.getErrorCode() == INEXISTENT_COLUMN_ERROR) System.out. Println("User friendly error message caused by column " + this. MatchPattern(e.getMessage(), this.

INEXISTENT_COLUMN_PATTERN)); if (e.getErrorCode() == DUPLICATE_DATA_ERROR) System.out. Println("User friendly error message caused by duplicate data " + this. MatchPattern(e.getMessage(), this.

DUPLICATE_DATA_PATTERN)); } ... private String matchPattern(final String string, final String pattern) { final Pattern p = Pattern. Compile(pattern); final Matcher m = p. Matcher(string); ... }.

My primary database is MSSql. Thank you =D – SLim Mar 6 at 14:03 @spencer you should have a look on google for a list of error codes from your vendor. But you could also figure them out for your self System.out.

Print(e.getErrorCode()) – klonq Mar 6 at 23:54 Thx =D failed to do in java because using eclipse, weak in debug but work in c# (visual studio) ^^ – SLim Mar 7 at 3:48.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send