RE: Connection.setCatalog()

From: jason(at)netspade(dot)com
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: RE: Connection.setCatalog()
Date: 2001-07-15 22:49:58
Message-ID: 7633909.995237398335.JavaMail.jason@www2.kc.aoindustries.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

[[[ Original Message from Peter Eisentraut <peter_e(at)gmx(dot)net> ]]]

> jason(at)netspade(dot)com writes:
>
> > Connection.setCatalog(String database) should connect to the specified database.
>
> The JDBC spec says:
>
> : Sets a catalog name in order to select a subspace of this Connection's
> : database in which to work. If the driver does not support catalogs, it
> : will silently ignore this request.
>
> Note the part about "subspace". In PostgreSQL, the database/catalog is
> fixed when the connection is established. On other systems you can
> probably change the database/catalog while keeping the connection. But
> you cannot establish a new connection if the spec says that this method
> should make a selection among the objects available in the current
> connection.

What do they mean by database though? It is vague because the definitions are not clear, but I interpret it like this: A "catalog" equals "PostgreSQL database" which is a subset of the whole "database" assuming "database" in this context to mean the whole server. I realise that the "catalog" is fixed but this is also the case for MySQL. Note it doesn't say "in current connection" so no reason why you can't create a new one. The bottom line is that supporting them would make life easier for people like me writing a database admin tool.

By the way, you've already applied my suggested changes to DatabaseMetaData.getCatalogs() - supporting that would imply supporting Driver.set/getCatalog().

You may want to check what other similar drivers do, but as far as I can see the only reason for not implementing catalog support is if you have a database (e.g. Interbase) where you only connect to one "catalog" which is a file location - you can't actually list other available catalogs.

I hope that clarifies the way I see it.

> > The DatabaseMetaData.supportsCatalogsInXXX() may need to be modified.
>
> These methods are all implemented correctly.
>
> > I'm not sure about the stuff in DatabaseMetaData.getTables() for
> > example - at the moment specifying null gets all the tables in the
> > database which the driver is currently connected to. I think this is
> > fine - but different database name patterns might be specified and
> > they may have to be implemented?
>
> Yup. We'll just throw an SQLException in that case.

Yes, that isn't really a problem. But _if_ you want to support catalogs maybe you have to go the whole way?

Thanks,

Jason Davies

jason(at)netspade(dot)com

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Peter Eisentraut 2001-07-16 20:17:18 RE: Connection.setCatalog()
Previous Message Bruce Momjian 2001-07-15 04:29:48 Re: [PATCHES] Re: [PATCH] Cleanup of JDBC character encoding