I am using MySql, JDBC, Java to make my code. I am unable to understand what some terms in the API mean. It is preventing me from doing the work below-
To make code that checks if a particular DB exists, then checks if a particular table DB exists in that DB, followed by a particular column in that table.
Each table description has the following columns:
TABLE_CAT String => table catalog (may be null)
TABLE_SCHEM String => table schema (may be null)
TABLE_NAME String => table name
TABLE_TYPE String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
REMARKS String => explanatory comment on the table
TYPE_CAT String => the types catalog (may be null)
TYPE_SCHEM String => the types schema (may be null)
TYPE_NAME String => type name (may be null)
SELF_REFERENCING_COL_NAME String => name of the designated "identifier" column of a typed table (may be null)
REF_GENERATION String => specifies how values in SELF_REFERENCING_COL_NAME are created.
Values are "SYSTEM", "USER", "DERIVED". (may be null)
What is a table catalog, what is a table schema, SELF_REFERENCING_COL_NAME etc ?
As far as Connector/J implementation of DatabaseMetadata is concerned
TABLE_CATreturns the database name (as in CREATE DATABASE);TABLE_SCHEMisnullandSELF_REFERENCING_COL_NAMEis not returned.This is database and driver specific. As an example, Oracle ojdbc drivers will return
nullforTABLE_CATand the object owner forTABLE_SCHEM.For your particular task (MySQL + Connector/J):
getCatalogs()to obtain aResultSet, iterate its rows and retrieve theTABLE_CATcolumn, your database should match one of its values.getTables(databaseName, null, tableName, new String[]{"TABLE"})should return a non emptyResultSet.getColumns(databaseName, null, tableName, columnName)should return a non emptyResultSet.