当前位置: 代码迷 >> Java相关 >> [求助]求教!!!JDBC
  详细解决方案

[求助]求教!!!JDBC

热度:390   发布时间:2005-09-28 09:48:00.0
[求助]求教!!!JDBC

我用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) { } } } } 大家帮忙了

搜索更多相关的解决方案: JDBC  

----------------解决方案--------------------------------------------------------
  相关解决方案