wood burning stoves 2.0*
The moose likes JDBC and the fly likes how to get the table name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to get the table name" Watch "how to get the table name" New topic
Author

how to get the table name

venkat
Greenhorn

Joined: Jan 23, 2000
Posts: 10
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

Joined: Mar 06, 2001
Posts: 13459

"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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get the table name