Hi David,

"Catalog" is an undefined term for Derby. In contrast, for another open source database, MySQL, "catalog" means "database". MySQL seems to have a concept of "databases managed by this server". Derby does not.

A Derby database can live anywhere in the file system and can be managed by any Derby engine running on the machine. You could speak of "databases potentially managed by this engine". Computing that list might mean scanning the entire file system which the engine has permission to read--and even looking inside all of the visible jar files since a read-only Derby database can be stored in a jar file. We might be able to give a well-defined meaning to "databases potentially managed by Derby", but I suspect that the devil is in the details.

You could also speak about "databases currently managed by this engine". That could mean all of the databases currently booted by a given Derby engine. That meaning seems limited and well-defined to me but I don't think it maps exactly to what another RDBMS might mean by "catalog".

What would you like "catalog" to mean for Derby?

Here are the results of the getCatalogs() and getCatalogTerm() calls for a Derby engine and a MySQL server. Here I am using the DBMDWrapper functions attached to DERBY-3973:

ij> -- Derby's list of catalogs
select * from table( getCatalogs() ) s;
TABLE_CAT
--------------------------------------------------------------------------------------------------------------------------------

0 rows selected
ij> -- Derby's preferred term for catalog
values ( getCatalogTerm() );
1
--------------------------------------------------------------------------------------------------------------------------------
CATALOG

1 row selected
ij> -- now ask MySQL the same questions
call setDatabaseURL( 'com.mysql.jdbc.Driver', 'jdbc:mysql://localhost/world?user=root&password=' );
0 rows inserted/updated/deleted
ij> -- MySQL's list of catalogs
select * from table( getCatalogs() ) s;
TABLE_CAT
--------------------------------------------------------------------------------------------------------------------------------
information_schema mysql test world

4 rows selected
ij> -- MySQL's preferred term for catalog
values ( getCatalogTerm() );
1
--------------------------------------------------------------------------------------------------------------------------------
database

1 row selected
ij> -- release the MySQL connection
call setDatabaseURL( '', '' );
0 rows inserted/updated/deleted

Hope this helps,
-Rick

Lance J. Andersen wrote:
Depends on the concept in Derby of what a catalog is as your mileage can vary between databases.
Some vendors treat it as the database name, others do not.

Null is allowed to be returned if the concept of catalog is not applicable to a given database

Regards
Lance

David Van Couvering wrote:
Shouldn't Connection.getCatalog() return the name of the database you are connected to, and shouldn't DMD.getCatalogs() return a result set with one row, representing the database you're connected to?

This is causing us a bit of a headache when we're trying to inspect a Derby database in NetBeans...

Thanks,

David
--
David W. Van Couvering
http://davidvancouvering.blogspot.com

Reply via email to