Announcement Announcement Module
Collapse
No announcement yet.
how to make an insert into sql database when one field is auto-generated/auto-increm? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to make an insert into sql database when one field is auto-generated/auto-increm?

    Hello

    I wish to insert a row into a table, in which there is an 'id' field of type integer which is auto-generated/auto-incremented.

    Along with the id field, there are some other integer/ varchar fields that have to be inserted.

    After the insert, I also wish to obtain the ID assigned to the row that was just inserted into database.

    I read through the docs but in the relevant section it says that the format of query can differ from case-to-case in such inserts (where a field is an auto-incrementing integer).

    Hence I wish to know if and what is the standard syntax for making such an insert using Spring JDBC?

    Thanks,
    Arvind.

  • #2
    You could use a SimpleJdbcInsert http://static.springsource.org/sprin...-jdbc-insert-2

    or a JdbcTemplate http://static.springsource.org/sprin...genereted-keys

    Cheers.

    Comment

    Working...
    X