请教DatabaseMetaData.getTables()方法中各参数的含义,严重谢!

nt941 2004-02-02 06:13:53
下面是JDK doc的讲解,在下看不懂,恳请高手指教!最好能举个例子。谢!

public ResultSet getTables(String catalog,
String schemaPattern,
String tableNamePattern,
String[] types)
throws SQLException

Retrieves a description of the tables available in the given catalog. Only table descriptions matching the catalog, schema, table name and type criteria are returned. They are ordered by TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.

Parameters:
catalog - a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search
schemaPattern - a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search
tableNamePattern - a table name pattern; must match the table name as it is stored in the database
types - a list of table types to include; null returns all types
...全文
380 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
playyuer 2004-02-02
  • 打赏
  • 举报
回复
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html#getTables(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String[])

class Class1
{
public static void main(String[] args) throws Exception
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
java.sql.DatabaseMetaData databaseMetaData = java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://yuer-mobile\\psqlkd;database=Northwind;User=sa;Password=").getMetaData();
java.sql.ResultSet resultSet = databaseMetaData.getTables(null,null,null,null);
while (resultSet.next())
{
System.out.println( resultSet.getString("TABLE_NAME"));
}
}
}
Jianli2004 2004-02-02
  • 打赏
  • 举报
回复
public ResultSet getTables(String catalog,
String schemaPattern,
String tableNamePattern,
String[] types)
throws SQLException

Retrieves a description of the tables available in the given catalog. Only table descriptions matching the catalog, schema, table name and type criteria are returned. They are ordered by TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.

Parameters:
catalog - a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search
schemaPattern - a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search
tableNamePattern - a table name pattern; must match the table name as it is stored in the database
types - a list of table types to include; null returns all types

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧