我用JDBC 连接 SQL Server2000,查询、更新都没问题,但查看数据库信息时,老失败, 我的程序如下: import java.sql.*; public class DataMeta { public static void main(String[] args) { Connection con=null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc:custom"; con = DriverManager.getConnection(url); Statement stmt = con.createStatement(); DatabaseMetaData dma = con.getMetaData(); ResultSet tables=dma.getTables(null,null,null,new String[]{"TABLE"}); ResultSet column;
String tablename,columnnames;
while(tables.next())
{ tablename=tables.getString("TABLE_NAME");
column=dma.getColumns(null,null,tablename,null);
System.out.println("Tablename: "+tablename);
while(column.next())
{
columnnames=column.getString("COLUMN_NAME");
System.out.println(columnnames);
}
System.out.println(""); } } catch (Exception e) {
e.printStackTrace(); } finally { try { con.close(); } catch (Exception e) { } } } } 大家帮忙了
----------------解决方案--------------------------------------------------------