import java.awt.*; import java.awt.event.*; import java.util.*; import java.sql.*; public class TableNameExample extends Frame { public TableNameExample () { super("TableNameExample"); this.setSize(300, 300); this.setVisible( true ); // Create the textarea to display the table name TextArea text = new TextArea(25, 80); this.add("Center", text); //Add ActionListener para Fechar Aplicacao this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); try { String driverName = "sun.jdbc.odbc.JdbcOdbcDriver"; Driver driver = (Driver)Class.forName(driverName).newInstance(); Properties p = new Properties(); p.put("user", "p8cp1"); p.put("password", "ismael"); String dbURL = "jdbc:odbc:fiaa"; Connection connection = driver.connect(dbURL, p); System.out.println("--- Conection established ---"); // Select all items from tEmployee String sql = "select * from Pessoa"; Statement sqlStatement = connection.createStatement(); ResultSet records = sqlStatement.executeQuery(sql); ResultSetMetaData metaData = records.getMetaData(); // Put the table name of the first column // into the text area object text.setText(metaData.getTableName(1)); } catch (SQLException e) {} catch (Exception e) {} } public static void main (String args[]) { TableNameExample app = new TableNameExample(); } }