this is the code:
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
public class GetRecords
{
public static void main(String [] args) throws SQLException
{
DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
Connection con=DriverManager.getConnection("Jdbc
dbc:vendsn1","scott","tiger");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(" select * from department");
ResultSetMetaData rsmd=rs.getMetaData();
boolean b = rsmd.isSearchable(1);
while(rs.next())
{
System.out.println(rs.getRow());
System.out.println(rs.getInt(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
System.out.println(rsmd.getColumnCount());
System.out.println(rsmd.getColumnDisplaySize(1));
System.out.println(rsmd.getColumnDisplaySize(2));
System.out.println(rsmd.getColumnDisplaySize(3));
System.out.println(rsmd.getColumnTypeName(1));
System.out.println(rsmd.getTableName(1));//to get the table name
System.out.println("-------");
}
rs.close();
stmt.close();
con.close();
}
}