• Post Reply Bookmark Topic Watch Topic
  • New Topic

preparestatment  RSS feed

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am doing like below.


It is not working. I am not getting the del cnt. It is throwing an exception.


Can anyone tell me what is wrong in the above code?

Thanks


 
Bartender
Posts: 2633
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

anvi kon wrote:Hi,... It is throwing an exception...

What does that exception say?
 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Exception says: you cannot rollback with autocommit set.


My question , Is the below code returns the int or not?




Thanks

 
author & internet detective
Marshal
Posts: 37688
574
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It returns the int on success.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it returns int for INSERT,UPDATE,DELETE statements and 0 for DDL statements. Check out this link..
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once Check you have delete permission or not..
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's something confused in your instruction.

You get the PreparedStatement from the connection with the method



and you pass to this method the sql query String

Then you invoke the super interface (Statement) version of executeUpdate with another sql query.

If the query is



then don't even use a PreparedStatement, but just a Statement


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37688
574
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Nicola Garofalo wrote:There's something confused in your instruction.

You get the PreparedStatement from the connection with the method



and you pass to this method the sql query String

Then you invoke the super interface (Statement) version of executeUpdate with another sql query


Good catch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!