This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

get max(id) from table  RSS feed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends

In my program i am getting max(ID) an interger value from the resultset.I don't know how to convert that into integer.


String s3 = "select MAX(ID) from SALES_EMPLOYEE_MASTER";
ResultSet resultset = statement.executeQuery(s3);



If I use int maxid=resulltset.getInt(1); , I ma getting error.Please help me to how to retrieve a interger value from the resultset..

Thanks in advance
Regards
 
Marshal
Posts: 56930
174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a similar problem last week, which turned out to be caused by not calling the next() method on my ResultSet object. Remember a ResultSet defaults to cursor on line "0" so you have to call next() (or first() or absolute(1) or similar) to get to a result at all.

If that doesn't help, please post some more code.
 
Sheriff
Posts: 22968
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or tell us what the error is. Details are always helpful, whereas vague statements like "I got an error" are not.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!