Sometimes getting names of the table columns is required. The code snippet does exactly that.

Java Code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection("jdbc:odbc:dd","","");
// Create a result set
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM test");

// Get result set meta data
ResultSetMetaData rsmd = rs.getMetaData();
int numColumns = rsmd.getColumnCount();

// Get the column names; column indices start from 1
for (int i=1; i                 {
String columnName = rsmd.getColumnName(i);

// Get the name of the column's table name
String tableName = rsmd.getTableName(i);
System.out.println("columnName "+columnName);