It's userful method. public void getColumnNames ( ResultSet rs ) throws SQLException { ResultSetMetaData rsMetaData = rs.getMetaData () ; int nCol = rsMetaData.getColumnCount () ; // get the column names for ( int i = 0 ; i < nCol ; i++ ) { String colName = rsMetaData.getColumnName ( i ) ; // Get table String tableName = rsMetaData.getTableName ( i ) ; } }