× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi,

For example:
Create table testTable (
   INT1 int ,
   DECIMAL1 decimal (9, 0),
   DECIMAL2 decimal (13,4),
   CHAR1 char (5)
)

the resultsetmeta information as following:
Column#1: name=INT1 size=11 scale=0 type=INTEGER Class=java.lang.Integer
Column#2: name=DECIMAL1 size=11 scale=0 type=DECIMAL Class=java.math.BigDecimal Column#3: name=DECIMAL2 size=15 scale=4 type=DECIMAL Class=java.math.BigDecimal
Column#4: name=CHAR1 size=5 scale=0 type=CHAR Class=java.lang.String

and DSPFFD as following:

Field Level Information Data Field Buffer Buffer Field Column Field Type Length Length Position Usage Heading INT1 BINARY 9 0 4 1 Both INT1 Allows the null value
 DECIMAL1   PACKED       9  0       5         5        Both     DECIMAL1

Allows the null value
 DECIMAL2   PACKED      13  4       7        10        Both     DECIMAL2

Allows the null value CHAR1 Open 5 5 17 Both CHAR1

When I use the ResultSetMetaData.getColumnDisplaySize(int columnindex) to get the filed size for char filed, the size equal to DLL definition, but when the field type is integer, decimal or numeric, the field size is field length in DDL + 2, what is reason for the deference ?

Best regads,

Vengoal


-------- Original Message  --------
From: Vengoal Chang <vengoal@xxxxxxxxxxx>
To: Java Programming on and around the iSeries / AS400 <java400-l@xxxxxxxxxxxx> Subject: Re:How do I retrieve the every field length defined in DDL with JDBC ?
Date: 2006/9/7 AM 09:25

Joe & Keith,
   Thanks your help.

Vengoal

-------- Original Message  --------
From: "Joe Sam Shirah" <joe_sam@xxxxxxxxxxxxx>
To: "Java Programming on and around the iSeries / AS400" <java400-l@xxxxxxxxxxxx> Subject: Re:How do I retrieve the every field length defined in DDL with JDBC ?
Date: 2006/9/7 AM 12:11

  Hi Vengoal,

  Depending on your needs, Keith's answer of
ResultSetMetaData.getColumnDisplaySize() is probably enough.  If you need
more information and specifics about the columns, you can also use
DatabaseMetaData.getColumns().

  There's actually an example of both methods in the list archives at:

http://archive.midrange.com/java101/200107/msg00035.html

  I also have an example using ResultSetMetaData.getColumnDisplaySize() to
set up a fixed font display in one of the exercises for my JDBC tutorial at
Sun's developer site.  The complete program is at:

http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/SRS/solution/ScrollResultJ.java


                                                       Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO       -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?            http://www.jguru.com/faq/Java400


----- Original Message ----- From: "McCully, Keith (RBS Insurance)" <Keith.McCully@xxxxxxxxx>
To: "'Java Programming on and around the iSeries / AS400'"
<java400-l@xxxxxxxxxxxx>
Sent: Wednesday, September 06, 2006 5:21 AM
Subject: RE: How do I retrieve the every field length defined in DDL with
JDBC ?




Hi Vengoal,

Create a ResultSetMetaData object then use its getColumnDisplaySize method
for every column.

If you want further info then refer to the JDBC API docs.

Regards,

Keith

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx]


Sent: 06 September 2006 04:56
To: Java Programming on and around the iSeries / AS400
Subject: How do I retrieve the every field length defined in DDL with JDBC
?


*** WARNING : This message originates from the Internet ***

Hi,
  I have one table created with following DDL:

CREATE TABLE ACTION
(
ACTIONCD      CHAR(1),
ACTDEP            CHAR(10),
DESCRIPTION  VARCHAR(80),
SHORTDESC    VARCHAR(10)
)

How do I retrieve the atble's  every field length defined in DDL with JDBC
?


Best regards,

Vengoal
--



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.