RE: Connection.setCatalog()
| От | jason@netspade.com |
|---|---|
| Тема | RE: Connection.setCatalog() |
| Дата | |
| Msg-id | 7633909.995237398335.JavaMail.jason@www2.kc.aoindustries.com обсуждение |
| Ответ на | Connection.setCatalog() (jason@netspade.com) |
| Ответы |
RE: Connection.setCatalog()
|
| Список | pgsql-jdbc |
[[[ Original Message from Peter Eisentraut <peter_e@gmx.net> ]]] > jason@netspade.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 tomean the whole server. I realise that the "catalog" is fixed but this is also the case for MySQL. Note it doesn't say "incurrent connection" so no reason why you can't create a new one. The bottom line is that supporting them would make lifeeasier 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 supportingDriver.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 catalogsupport 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@netspade.com
В списке pgsql-jdbc по дате отправления: