• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get the table name

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
}
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic