当前位置:首页 > 开发 > 编程语言 > 编程 > 正文

jdbc 获得sqlserver 元数据

发表于: 2014-11-26   作者:coldg   来源:转载   浏览:
摘要: DatabaseMetaData dmd = conn.getMetaData(); ResultSet res = dmd.getTables(conn.getCatalog(), null,null,new String[] {"TABLE"}); System.out.println("List of tables: ");
	DatabaseMetaData dmd = conn.getMetaData();
	ResultSet res = dmd.getTables(conn.getCatalog(), null,null,new String[] {"TABLE"});
		System.out.println("List of tables: "); 
	      while (res.next()) {
	         System.out.println(
	            "   "+res.getString("TABLE_CAT") 
	           + ", "+res.getString("TABLE_SCHEM")
	           + ", "+res.getString("TABLE_NAME")
	           + ", "+res.getString("TABLE_TYPE")
	           + ", "+res.getString("REMARKS")); 
	      }

返回结果: 

List of tables: 

   Northwind, dbo, Categories, TABLE, null

   Northwind, dbo, CustomerCustomerDemo, TABLE, null

   Northwind, dbo, CustomerDemographics, TABLE, null

   Northwind, dbo, Customers, TABLE, null

   Northwind, dbo, Employees, TABLE, null

   Northwind, dbo, EmployeeTerritories, TABLE, null

   Northwind, dbo, Order Details, TABLE, null

   Northwind, dbo, Orders, TABLE, null

   Northwind, dbo, Products, TABLE, null

   Northwind, dbo, Region, TABLE, null

   Northwind, dbo, Shippers, TABLE, null

   Northwind, dbo, Suppliers, TABLE, null

   Northwind, dbo, Territories, TABLE, null

jdbc 获得sqlserver 元数据

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号