What Are Catalogs and Schemas? JDBC

If you want to provide catalog and schema services to database applications, then you might need to provide catalog and schema values to client applications. The words catalog and schema have different meanings, depending on the database vendor. Again, the vendor parameter is very important in understanding the semantics of catalogs and schemas. Oracle treats “schema” as a database name, while MySQL treats “catalog” as a database name. So, in order to get the name of databases from Oracle, you must use getSchemas(); to get the name of databases from MySQL, you must use getCatalogs(). If you use getCatalogs() for an Oracle database, or getSchemas() for MySQL, it returns nothing (as null objects). In the JDBC API, getSchemas() claims that it returns a set of two columns (“table schema” and “table catalog”), but in reality it just returns “table schema” as a first column of the result set. Once again, this proves at least two points:

  • You have to test your code against different databases; that is, databases can have different semantics by using the same JDBC API.
  • When you define connections, make sure that the vendor parameter is defined. When you know the database vendor, you can invoke the correct methods.

getSchemas() Used for an Oracle Database

getCatalogs() Used for a MySQL Database



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JDBC Topics