This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Leading zeroes in an Integer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Leading zeroes in an Integer" Watch "Leading zeroes in an Integer" New topic
Author

Leading zeroes in an Integer

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
My data field allows leading zeroes with a maximum length of 3.
e.g. "001", "1", "123", "456" are all valid but "1234", "0001" are not valid.
One solution is to define the data field as CHAR(3) in the DB2 database.
Is it possible that the data field in the DB2 database be defined as INTEGER so that the leading zeroes are still preserved (i.e. “001” is different from “1”)?
If that is possible, how to manipulate the data field by Java?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30050
    
149

albert kaoIs it possible that the data field in the DB2 database be defined as INTEGER so that the leading zeroes are still preserved (i.e. “001” is different from “1”)?[/quote wrote:
No. You need to use char if you want to differentiate between the two.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Leading zeroes in an Integer
 
Similar Threads
JAVA TREE
How to think in Octal?
Dropping leading zeros on numeric field
Tips on form-based authetication
Can somebody write a toHex() for me ?