Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

auto increment a number

 
avijit shaw
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,


i want to auto increment a field of my database(say id field) using java code.
i have a insert form in jsp page, by click on the submit button it will insert the value.
but he thing is thatin my table i have two fields id and name.but in in the form there is only one foeld that is name.whenever i insert a name and submit,
the id field of the database auto generate d a number and incremented by one on every post action....


how to do???

plzzzz solve this.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avijit,
Welcome to JavaRanch!

If the database is generating the key, you just need to insert the name. The database will take care of the id for you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic