File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes Generating primry keys Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Generating primry keys" Watch "Generating primry keys" New topic

Generating primry keys

Piradharsan Navaratnam

Joined: May 15, 2007
Posts: 14
Friend How can I create unique primary keys in java or in mysql.

Please read this...........

There are lot of speed posts(type of mail/letter) are accepted in our postoffices. I need to uniquely identify them. I thought to generate a unique id like this.

Say its 04thJune07 then
the ids will propogate like 040607(a unique post office id - 5 digits)(auto increment letter id)

For example 040607907361
040607 is the date, 90736 is the post office code (there are unique code for every post offices), 1 is the autoincrement no.

Can any body help me?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 61594

Please take the time to choose the correct forum for your posts. This forum is for questions on Servlets.

This post has been moved to a more appropriate forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

Here's a Google search command that searches the official mysql site for autoincrement within a CREATE TABLE SQL command:

create table autoincrement

I agree. Here's the link:
subject: Generating primry keys