aspose file tools
The moose likes JDBC and the fly likes exception Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "exception" Watch "exception" New topic
Author

exception

Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
i set the field to unique in mysql database.
when i input data into the field, the alert message shown in mysql: can't insert duplicate value for that field.

but when i input same data in that field from jsp and then submit form
i would like to ask why the code don't fall to exception as i use
try{

update sql statement here...
return "updated";
}
catch(exception e){
return e.toString();
}

but actually, the data has not been updataed.
but can't fall to exception area?

why?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Li Jenny wrote:
i would like to ask why the code don't fall to exception as i use
try{

update sql statement here...
return "updated";
}
catch(exception e){
return e.toString();
}

but actually, the data has not been updataed.
but can't fall to exception area?

how do you say that it is not falling into catch block? put System.out.println("INFO:cool! i am here") this as a first statement in catch . and let me know


<edit>by the way : dont you get compilation error on catch[catch(exception e)] . remember, java is case sensitive</edit>
Devaka Cooray
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2691
    
    3

Jenny, please UseCodeTags when you post source code on JavaRanch.
Moving to JDBC.


Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseAMeaningfulSubjectLine when posting. Explaining your question or remark briefly on the subject line allows us to know what we are getting into, and if we will be able to help. Taking the time to compose a useful subject line shows that you care enough about your question to ShowSomeEffort when asking it here.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: exception
 
Similar Threads
A Castor question
How can I stop the object to be created
Batch inserts exception getting thrown..
To insert value from text field into MySQL database
insert chinese character jsp/java servlet