• Post Reply Bookmark Topic Watch Topic
  • New Topic

about executeUpdate

 
jerry chi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i want to insert a record into table with PreparedStatement.executeUpdate function. when does it return 0 whithout an SQLException occured?

thanks
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you provide code snippet ???
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shailesh Chandra:
can you provide code snippet ???


why you need a code snippet Chandra.
Jerry you should read the docs for this question, what you think?
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by adeel ansari:


why you need a code snippet Chandra.


I have never come across a scenario when there is no insert ,also there is no exception. so just wanted to verify code
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36032
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This can happen if you do an insert based on values from another table. If the select doesn't return any rows, you are inserting zero rows into a table. There isn't an exception because you aren't violating any constraints.

 
jerry chi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Jeanne
i think there is no other case than what you said.
if i just insert a record whithout select clause, i needn't judge whether the function returns zero. is that right.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36032
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jerry,
I think that is right. All the other reasons for failure that I can think of would thow an exception.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!