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

prepareStatement returns 0?

 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Report post to moderator
I have a problem. PrepareStatement returns 0 in my code but the query returns the correct result in my sql editor?!

I�m working within a servlet. First I do make a database connection and share that connection through the servlet lifetime... Inside the doPost method I first call a synchronized method which do the following task:

synchronized method_1 ()
1) SELECT MAX(id)
2) UPDATE date for the max(id) (I use type 2 historic)
3) INSERT request values
4) SELECT MAX(id) (from the insert)
5) return new MAX(id)

- That works fine. After that I call yet another synchronized method where I do the same task, just in another table:

synchronized method_2 ( int invoiceID )
1) SELECT MAX(id) returns 0 //FAILS!
2) ...

I close my resultSet after every Query. I have tried to close my preparedStatement too (stat.close()). I have also tried to close my connection after doing the task in each synchronized method, and open a new connection. That doesn�t work either...

The code looks like the following:




[ January 29, 2005: Message edited by: Jeppe Fjord ]
[ January 29, 2005: Message edited by: Jeppe Fjord ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Jeppe,
Are you sure the inserts are being committed to the database? Also, out of curiousity, why are you using a synchronized method rather than a transaction?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Jeppe, please do not re-post the same question more than once. Please continue any discussion in the original post.
[ January 29, 2005: Message edited by: Bear Bibeault ]
 
    Bookmark Topic Watch Topic
  • New Topic