I think the database constraints are anyway necessary unless your database
is set up for table level locking or with isolation level serializable as it
would be possible for another txn to insert the record after your first
txn's select. Since these constraints exist in the database, the
corresponding exceptions need to be caught and handled, I guess.

Cheers,
Krishna

-----Original Message-----
From: Alireza Fattahi [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 09, 2003 4:41 PM
To: 'Struts Users Mailing List'
Subject: Error Handling Database constraints 


Hi,     

As we know there are two types of errors.

1) The user input error, for example and email without @. Well this can be
handled easily and *separately from code* by commons validation frame work

2) The errors that violate the database consistency. For example in the user
table the user_name filed must be unique. The thing we do is: first we add a
constraint to database for user_name. Then when an insert requests first we
select user_name from database to see if there is any duplicate. Well it
means that we handle the constraint checking task our selves with java code.
Why do we do this? Why did we just let the insert happens and work with
SQLException? Because the returned error from database can not be handled or
modified nicely. These errors are changed for each database.
 
Are we doing the right way? Is there any better way available for error
handling Database Constraints? 


Alireza.

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to