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:
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 ?