JDBC records retrieve in primitive type as 2D array to be store in excel

I am coding an application to export data from database to excel file using JExcelAPI.

Using the ResultSetMetaData class I am able to get the java.sql.Types of the columns. I used switch statement to convert the data to Objects.

example:

switch (type)

case Types.INTEGER// Wrap with Integer class

// al other types...

than store as Object[][] to be written to excel for convenience as excel use columns, row for their cells value.

Is there any other way I can detect the column type and wrap it with the appropriate class?

[701 byte] By [liangtehza] at [2007-11-27 11:17:51]
# 1

re-phrase my question... How do I map the SQL type to Java data type more effectively as compare to what I am doing now.

liangtehza at 2007-7-29 14:27:20 > top of Java-index,Java Essentials,New To Java...
# 2

u can use

http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSetMetaData.html#getColumnType(int)

link

student-javaa at 2007-7-29 14:27:20 > top of Java-index,Java Essentials,New To Java...
# 3

Using it. Running every column getting the sql data types pass it to switch statement and wrap it with the appropriate class. But I find it a hassle. Is there any other alternatives I can do dynamic type casting?

liangtehza at 2007-7-29 14:27:20 > top of Java-index,Java Essentials,New To Java...