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 How to get table's Integer field column size?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to get table Watch "How to get table New topic
Author

How to get table's Integer field column size??

Hetal Thakkar
Greenhorn

Joined: Jul 21, 2005
Posts: 5
hii,
i am retriving table's cloumn sizes in which i am getting String column sizes perfectly by getColumnDisplaySize() method.but it doesnt give the size of any number field.it gives the 22 for all the integer columns....so is there any other method for this???
please give me quick reply...
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31075
    
232

Hetal,
What would it mean to have a size for an Integer? The number of digits?

The database stores an integer as data (bytes.) You could calculate the number of digits in a value (or in max int) yourself though.


[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
Hetal Thakkar
Greenhorn

Joined: Jul 21, 2005
Posts: 5
hey,
i am using ResultsetMetaData,thru which i am taking max value which can be
inserted in the database.i am getting right values thru getCloumnDisplaySize() method for String column of a table.but it gives length of 22 for all integer values of all the tables in the database.i am creating dynamic insert query for which i am requing this..
Rajesh Agarwal
Ranch Hand

Joined: Aug 01, 2005
Posts: 79
Hetal,

try

int size = resulset.getMetaData().getPrecision(1);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get table's Integer field column size??