Semantic of getTables

From: Chris Forkin (cforkin_at_hotmail.com)
Date: 01/05/04

  • Next message: newsadict: "Database metadata"
    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.


  • Next message: newsadict: "Database metadata"

    Relevant Pages

    • Re: Designing a CD Database - How to Start?
      ... > Any suggestions for designing a CD database? ... > need to have some sort of catalog of "the collection". ... My advice is to keep your schema as simple as possible. ... Here's the database in sqlite3 binary format: ...
      (rec.music.classical.recordings)
    • Re: How to know columns names in Derby database table
      ... ResultSet getColumns(String catalog, ... String tableNamePattern, ... TABLE_SCHEM String => table schema ... reference attribute ...
      (comp.lang.java.databases)
    • Re: Catalog & Schema
      ... catalog = database, schema = schema ... you will need to run your own SQL for this. ...
      (comp.lang.java.databases)
    • Re: Catalog & Schema
      ... catalog = database, schema = schema ... SQL Server: catalog = database, ...
      (comp.lang.java.databases)
    • Re: Metadata versioning
      ... > growing database applications as clients evolve with versions. ... to store the metadata version information. ... I created a set of classes to completely describe the metadata or schema ... catalog tables, and schema reading routines, I can move between metadata ...
      (borland.public.delphi.non-technical)