I have a ResultSet that returns data of different types. The query is constructed dynamically so, at compile time, I don't know what type of value the query will return.
I have written the following code assuming that all results are Strings. But I want to get the type of each value too. How can I do this?
Below is the code I have written.
while (reportTable_rst.next()) {
String column = reportTable_rst.getString(columnIterator);
}
At this point, I would like to get the column type, and get the value according to the data type.
while ( rsdata.next() ) { for ( int i = 0; i < col_size; i++) { columnValue = rsdata.getObject(i+1); pstmtInsert = conRenameInfo.prepareStatement("INSERT INTO " + tableName + " (" + columnName + ") VALUES (?) "); pstmtInsert.setObject(1, columnValue); pstmtInsert.executeUpdate(); } }
– Graticule