aspose file tools
The moose likes JDBC and the fly likes auto_increment in mySql Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "auto_increment in mySql" Watch "auto_increment in mySql" New topic
Author

auto_increment in mySql

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi All,

is there any way to auto_increment backwards (-1, -2, -3) in mysql?
or to have an ID which increments like this:
J193
J194
J195
j196

etc?
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
I don't think this is possible within MySQL, or any other DB that I know of. If you are using hibernate you could write your own id generator. Otherwise I think you would have to lock the table, query for the last id, then generate the next one all in your java code.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: auto_increment in mySql
 
Similar Threads
MySQL + Eclipselink - SEQUENCE table
How to create a sequence in MySql5.0
auto_increment primary key
MySQL auto_increment and EJB
inserting data of two forms into two tables with same transaction id