• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unique sequence number

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to generate a unique sequence number in java that should be a int.
I need this number in my SMPP module.

i can generate this in String as UUID.randomUUID().toString();
and in long as Calendar.getInstance().getTimeInMillis();

but unable to do that for int. Can anybody help me for this???
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
salvin francis
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
or more simpler ... you may convert the long milliseconds of calendar into int.
 
Suchi Choudhary
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is what i have tried initially but the error which i got is that when i restarted the server.
after restart, the number again starts with the same number making duplicate entries in the database.

we can use the number again if it is 24 hours old i.e we can use a number once in a day as sequence number.
the things starts when i restarted the server twice or thrice a day.

Any help?
 
Suchi Choudhary
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

or more simpler ... you may convert the long milliseconds of calendar into int.




you can try this one, it throws NumberFormatException as we are trying to convert a long into int.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it an unique sequential number or an unique random number? If it is an unique sequential number and you are using database then whats wrong in fetching the last sequence number from database and add 1 the that.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do a search; there have been quite a lot of similar questions here and in beginners'.
 
reply
    Bookmark Topic Watch Topic
  • New Topic