--- Francisco Exposito Aguilera wrote: > What is the best way to show the user this sql error?
I'm skeptical that you'd want to show the *user* an SQL error; my experience has been that it's best to wrap up such exceptions in an application-specific exception and report a general system error (or even a database error) and leave the specifics to a log message, email or IM to the admin, etc. > 2.Before execute the createUser bean method, execute > another method to check if the user already exists. > If it exists, use ActionMessages in the action > class to show the error in the same createUser.jsp > file. > > That means that if the user doesn´t exist, the > action method will access, at least twice to the > database, one for check if the user exists and one > for create it. I would think you'd have to do that anyway. > java.sql.SQLException: ORA-00001: unique restriction > (PK_USER) violated > > a) Primary key is violated (java.sql.SQLException: > ORA-00001: unique > restriction (PK_USER) violated) > > b) Name and both surnames are unique > (java.sql.SQLException: ORA-00001: > unique restriction (U_NAME_SURNAME1_SURNAME2_U) > violated) I would most certainly *not* expose *any* system internals on a user-accessible web page. > Depending on the exception, I want to show primary > key exists or name and surnames exists with another > primary key Useful for developer, useless for user. All the *user* needs to know that another user with the same username exists and they need to choose another username or if they forgot their password they can click here, etc.) Keep user messages simple and jargon-free. It's easy enough to capture complete failure info for the developer somewhere else. (You can't restrict on just their real name because people have the same names sometimes.) d. ____________________________________________________________________________________ Don't get soaked. Take a quick peak at the forecast with the Yahoo! Search weather shortcut. http://tools.search.yahoo.com/shortcuts/#loc_weather --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]