Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

preparestatment

 
anvi kon
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


 
Jan Cumps
Bartender
Posts: 2602
13
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

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It returns the int on success.
 
YogeshS Pandit
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..
 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once Check you have delete permission or not..
 
Nicola Garofalo
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: 34973
379
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