Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with bulk update and auto_increment

 
Ravinder Rana
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need some help from you guys regarding bulk update. The scenario is as follows:

I have 3 tables in my DB: Person, Person_Phone_Numbers and Person_custom_info

Person table has a id(AUTO_INCREMENT)and Person_Phone_Numbers and Person_custom_info tables has this as their foreign key.

The no. of records which I have to insert at a time will be somewhere between 50 to 200, so I want to do a batch insert i.e. first insert all Person info followed by Person_Phone_Numbers and Person_custom_info.

Now the problem is, to insert data in Person_Phone_Numbers and Person_custom_info tables I need the Person ID value's. Is there a way to get these values? I am using MySQL as database.

All inputs appreciated.

Thanks
 
Jan Cumps
Bartender
Posts: 2584
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use java.sql.Statement.getGeneratedKeys().
It's documented in the MySQL 5.0 Reference Manual, 23.4.5.1. Basic JDBC Concepts:
23.4.5.1.4. Retrieving AUTO_INCREMENT Column Values.

Regards, Jan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic