jdbc 获得sqlserver 元数据

	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

你可能感兴趣的:(java)