Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get the table name

 
venkat
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
}
}
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"venkat",
please see requests to change your display name here, here and
here.

This is your last warning before your account is closed. Please change it immediately.

thanks,
Dave
[ September 10, 2005: Message edited by: David O'Meara ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic