File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes auto_increment in mySql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: auto_increment in mySql