Display Database Column name in java

by Vinoth 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);
}

Tagged in:

1615
like
0
dislike
0
mail
flag

You must LOGIN to add comments