Results 1 to 4 of 4
  1. #1
    CrOnNoS is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Default Problem with ResultSetMetaData getPrecision and getScale on .DBF files.

    Its just like the topic name says. Being more specific:
    Im using the following methods to test:
    Java Code:
        public static void main(String[] args) {  
           try {  
              ConexaoDBASE conexaoDBASE = new ConexaoDBASE();  
              conexaoDBASE.conectar(DBases.AIH);  
              Connection conexao = conexaoDBASE.getConexao();  
              ResultSet resultado = BancoDAO.lerBancoCompleto(conexao, "Morb");  
              ResultSetMetaData metaData = resultado.getMetaData();  
       
              for (int i = 1; i <= metaData.getColumnCount(); i++) {  
                 System.out.println(metaData.getColumnName(i));  
                 System.out.println(metaData.getPrecision(i));  
                 System.out.println(metaData.getScale(i));  
                 System.out.println(metaData.getColumnDisplaySize(i));  
                 System.out.println();  
              }  
       
           } catch (Exception e) {  
              e.printStackTrace();  
           }  
    
        } // main
    First i connect on the .dbf file which i would like to obtain the meta data and then i effective make the tests on the "for".
    The problem happens when the column type is Numeric. The getPrecision method aways returns 15 and the getScale aways return 0.
    Here some test results, three of the .DBF columns are those:

    UTI_INT_TO N 2 0
    PROC_REA C 8 0
    VAL_SH N 13 2

    "Column Name, Type (N = Numeric, C = Char), Number of values before the comma, Number of values after the comma".

    That data was extracted from the .DBF itself, and when the method i posted execute, it write:

    UTI_INT_TO
    15
    0
    22

    PROC_REA
    8
    0
    8

    VAL_SH
    15
    0
    22

    For Char columns, the method correctly return me the capacity of characters which this time was 8. But for Numeric type, the metho getPrecision AWAYS return 15 and the Scale AWAYS return 0, no matter what the real values are.
    Anyone got any idea about this problem or other solution to obtain the meta data that i want ?

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Please read the API specs for ResultSetMetaData to find out what those methods return.

  3. #3
    CrOnNoS is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Default

    i read before but yet just read again. So, what is the point ? Maybe im missing something but i dont think so since these methods work the way i want when i test on the postgreSQL :/

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    The methods don't give properties of values in the rows, but properties of columns as per the column definition.

Similar Threads

  1. Problem Jar executable files
    By Manfizy in forum New To Java
    Replies: 6
    Last Post: 08-13-2009, 01:15 PM
  2. problem communication between 2 files
    By Questionmark in forum AWT / Swing
    Replies: 6
    Last Post: 07-30-2009, 11:23 AM
  3. Data Files - A problem that I dont understand :D
    By Exhonour in forum New To Java
    Replies: 7
    Last Post: 01-20-2009, 05:13 AM
  4. resultsetmetadata
    By thamizhisai in forum Advanced Java
    Replies: 1
    Last Post: 05-27-2008, 07:41 AM
  5. Problem with executing .jar files
    By hiranya in forum NetBeans
    Replies: 2
    Last Post: 10-02-2007, 07:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •