import java - Dei-Isep

Propaganda
import java.sql.*;
public class MetaData {
private String nomeBD = "biblioteca.mdb";
private String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
public MetaData()
{
try {
Class.forName(driver);
System.out.println("Driver carregado ...");
String nomeCompletoBD =
getClass().getResource(nomeBD).getFile().substring(1);
System.out.println(nomeCompletoBD);
Connection ligacao = DriverManager.getConnection(
"jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + nomeCompletoBD);
DatabaseMetaData dbmd = ligacao.getMetaData();
/*
ResultSet getTables(String catalog,
String schemaPattern,
String tableNamePattern,
String[] types) throws SQLException
*/
String[] tableTypes = { "TABLE"};
// Para mostrar só tabelas
ResultSet tables = dbmd.getTables(
// Obtem info das tabelas
null,
null,
null,
tableTypes);
// null retornaria todos os tipos de tabelas
Tabela t = new Tabela(tables);
} catch(ClassNotFoundException cnfe) {
System.err.println(cnfe);
} catch(SQLException sqle) {
System.err.println(sqle);
}
}
public static void main(String[] args) {
MetaData dbmd = new MetaData();
}
}
Download