Attempting to iterate the Resultset returned by DatabaseMetadata.getColumns for a table with a DECIMAL, NUMERIC column etc. will result in a run time exception for column index 9 (DECIMAL_DIGITS).
ResultSet columns = dbMeta.getColumns( null, null, "TDEC", "%");
printRs("getColumns", columns, columns.getMetaData().getColumnCount());
private void printRs(String header, ResultSet rs, int cols) throws SQLException{
System.out.println(header);
if (rs == null) {
System.out.println("ResultSet was null");
}
long rows = 0;
while (rs.next()) {
for (int i = 1; i <= cols; ++i){
System.out.print( rs.getObject(i));
if (i < cols) {
System.out.print(",");
}
}
++rows;
System.out.println();
}
System.out.println("Rows printed " + rows);
}
create table if not exists TDEC ( RNUM integer not null , CDEC decimal(7, 2 ) );
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at com.mapd.jdbc.MapDResultSet.getObject(MapDResultSet.java:557)
at VendorTest.printRs(VendorTest.java:87)
at VendorTest.dumpColumns2(VendorTest.java:75)
at VendorTest.main(VendorTest.java:132)
Attempting to iterate the Resultset returned by DatabaseMetadata.getColumns for a table with a DECIMAL, NUMERIC column etc. will result in a run time exception for column index 9 (DECIMAL_DIGITS).
create table if not exists TDEC ( RNUM integer not null , CDEC decimal(7, 2 ) );
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.rangeCheck(ArrayList.java:653) at java.util.ArrayList.get(ArrayList.java:429) at com.mapd.jdbc.MapDResultSet.getObject(MapDResultSet.java:557) at VendorTest.printRs(VendorTest.java:87) at VendorTest.dumpColumns2(VendorTest.java:75) at VendorTest.main(VendorTest.java:132)
https://docs.oracle.com/javase/8/docs/api/java/sql/DatabaseMetaData.html#getColumns-java.lang.String-java.lang.String-java.lang.String-java.lang.String-