Semantic of getTables
From: Chris Forkin (cforkin_at_hotmail.com)
Date: 01/05/04
- Previous message: Aleksey Beregov: "Oracle JDBC under heavy load"
- Next in thread: Joe Weinstein: "Re: Semantic of getTables"
- Reply: Joe Weinstein: "Re: Semantic of getTables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 4 Jan 2004 20:17:11 -0800
Hi there,
I'm having some issues with the method
java.sql.DatabaseMetaData#getTables(String, String, String, String[])
and Microsoft's SQLServer JDBC driver.
According to the javadocs in the following code the ResultSet r should
contain
all tables in all schemas and catalogs:
...
String url = "jdbc:microsoft:sqlserver://localhost:1433;";
String user = "sa";
String passwd = "password";
Connection c = DriverManager.getConnection(url, user, passwd);
DatabaseMetaData m = c.getMetaData();
// catalog=null --> no restriction on catalog!
// schema=null --> no restriction on schema!
ResultSet r = m.getTables(null, null, "%", null);
...
This code works with other databases and the newest javadocs clarify
the somewhat ambiguous semantics of earlier java.sql API releases as
follows
(see http://java.sun.com/j2se/1.4.1/docs/api/java/sql/DatabaseMetaData.html#getTables(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String[])
):
----<quote start>----
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
----<quote end>----
In other words supplying catalog=null and schemaPattern=null should
retrieve
all tables regardless of their catalog and/or schema.
This however is not the case. In my case here, only tables belonging
to
"Northwind" are retrieved.
Is this a bug in com.microsoft.jdbc.sqlserver.SQLServerDriver et al.
or a
blunder from my side.
Hoping for some enlightenment, Regards, Chris.
- Previous message: Aleksey Beregov: "Oracle JDBC under heavy load"
- Next in thread: Joe Weinstein: "Re: Semantic of getTables"
- Reply: Joe Weinstein: "Re: Semantic of getTables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|