Display Database Column name in java
by Vinoth[ Edit ] 2010-02-02 15:42:35
The Below code will display the column names in a table.
PreparedStatement pre = conn.prepareStatement("select * from tb_1");
ResultSet res = pre.executeQuery();
ResultSetMetaData rsMetaData = res.getMetaData();
int cals = rsMetaData.getColumnCount();
for (int i = 1; i < cals + 1; i++) {
String columnName = rsMetaData.getColumnName(i);
out.println(columnName);
}