Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to generated unique value by Java and mysql

 
Mullin Yu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to generate a unique no. in the format like
yyyymmddxxxxxx (xxxxxx 6-digitl running number)

I think of create a table with two columns

date value
20050405 120
20050406 99

Everytime, the application will increase the value+1 based on the same date. If not date found, create one record and value = 1

The problem is that since there's no transaction at mysql 4.1.x that even the application
1. insert value
2. max() to get
max() may not get the value just insert BECAUSE there may be MULTI-threads/users

How can implement so with Java and mysql?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic