This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Select max id and calling method from another class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Select max id and calling method from another class" Watch "Select max id and calling method from another class" New topic
Author

Select max id and calling method from another class

Joseph Smithern
Ranch Hand

Joined: Feb 11, 2006
Posts: 89
I have a method that has a prepared statement that executes before a SQL select max id query. The Prepared statement works great where I call it in another method in my Java Helper Class file.

Now I want to move the method with the prepared statement into another class and call in in my Java Helper Class.

For some reason it didnt work. Here is what it looked like with both methods in one class and everything working great with my Access 2003 database where the prepared statement runs and then I get the max id from the table:



Now if I put the insertData method in another class and call it in the HelperDB class it will correctly insert data into tableone but it doesnt retrieve the correct max tableoneid value.





It seems like the the object new AnotherHelper().insertData(user) runs after the select max sql statement (select max(tableoneId) from tableone) because I always get the second to last max value from tableone. Please advise.
[ October 02, 2007: Message edited by: Joseph Smithern ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Select max id and calling method from another class
 
Similar Threads
how to convert to statements to an array
Validation/DB query question
Adding code to return an ArrayList of objects
Transaction Management
How to insert/Retrieve object as Blob to/from database table?