hi am making project..i have entered the record in 8 columns of table using jdbc and 9th column is automatically icremented as primary..so after putting the record and executin query i want to check primary no which i get..i want to show it in text box..what can be the query...??
pls reply...

Recommended Answers

All 2 Replies

It depends on the database that you are using. Different databases have different ways of dealing with auto-incremented keys like that.

hi am making project..i have entered the record in 8 columns of table using jdbc and 9th column is automatically icremented as primary..so after putting the record and executin query i want to check primary no which i get..i want to show it in text box..what can be the query...??

Use the `getGeneratedKeys()` method of the statement object.

Just make sure that when executing the statement you pass in the "Statement.RETURN_GENERATED_KEYS" flag as the second parameter. Follow the instructions here and make sure that you have created a table which explicitly has a auto-incrementing column.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.