Getting the JDBC column types
The parameters to DatabaseMetaData.getColumns(..)
are supposed to be a LIKE
-pattern. So if you want to get all columns from a table, you simply need to pass in "%"
to the last parameter, columnNamePattern
:
getMetaData().getColumns(null, schema, tableName, "%");
Some drivers (also) allow null
here, but not all drivers do that (the JDBC specification and API documentation is not entirely clear whether that is allowed or not for this parameter)
Use jdbc ResultSetMetaData class to get the detail information of the table columns.
ResultSet res=stmt.executeQuery("select * from tableName where 1<0");
ResultSetMetaData rsmd=res.getMetaData();
rsmd.getColumnType(1);
rsmd.getColumnLabel(1);
rsmd.getColumnDisplaySize(1);