Win a copy of The Business Blockchain this week in the Cloud forum!
  • 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
Marshal
Posts: 35266
383
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
Marshal
Posts: 35266
383
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic