• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

primary generator using MySQL

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, guys:

I need a primary key (sequence) generator for multiple tables.

I will have to programatically store/retrieve primary keys and save them as
foreign keys for other tables using Java JDBC.

I also looked at AUTO_INCREMENT of MySQL, but how can I use it for multiple tables and retrieve the most recent key to use without producing duplications?

regards,
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've not done it, but I'd think you could use auto increment and then Statement.getGeneratedKeys() (which of course PreparedStatement inherits...)
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by stu derby:
I've not done it, but I'd think you could use auto increment and then Statement.getGeneratedKeys() (which of course PreparedStatement inherits...)



I don't know that the MySQL JDBC driver supports that method. Last time I tried it did not.
reply
    Bookmark Topic Watch Topic
  • New Topic