Package io.github.connellite.jdbc
Class DatabaseMetaDataUtils
java.lang.Object
io.github.connellite.jdbc.DatabaseMetaDataUtils
Thin helpers over
DatabaseMetaData that read common identifier columns into ordered, de-duplicated string collections.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<String>getCatalogs(Connection connection) DatabaseMetaData.getCatalogs()—TABLE_CATvalues.static Collection<String>getColumns(Connection connection, String tableName) DatabaseMetaData.getColumns(String, String, String, String)—COLUMN_NAMEvalues.static Collection<String>getColumns(Connection connection, String catalog, String tableName) DatabaseMetaData.getColumns(String, String, String, String)—COLUMN_NAMEvalues.static Collection<String>getColumns(Connection connection, String catalog, String schemaPattern, String tableName) DatabaseMetaData.getColumns(String, String, String, String)—COLUMN_NAMEvalues.static Collection<String>getColumns(Connection connection, String catalog, String schemaPattern, String tableName, String columnNamePattern) DatabaseMetaData.getColumns(String, String, String, String)—COLUMN_NAMEvalues.static Collection<String>getExportedKeys(Connection connection, String table) DatabaseMetaData.getExportedKeys(String, String, String)—PKCOLUMN_NAMEon this table as referenced primary key.static Collection<String>getExportedKeys(Connection connection, String catalog, String table) DatabaseMetaData.getExportedKeys(String, String, String)—PKCOLUMN_NAMEon this table as referenced primary key.static Collection<String>getExportedKeys(Connection connection, String catalog, String schema, String table) DatabaseMetaData.getExportedKeys(String, String, String)—PKCOLUMN_NAMEon this table as referenced primary key.static Collection<String>getFunctionColumns(Connection connection, String functionNamePattern) DatabaseMetaData.getFunctionColumns(String, String, String, String)—COLUMN_NAMEper row (function parameter/result columns).static Collection<String>getFunctionColumns(Connection connection, String catalog, String functionNamePattern) DatabaseMetaData.getFunctionColumns(String, String, String, String)—COLUMN_NAMEper row (function parameter/result columns).static Collection<String>getFunctionColumns(Connection connection, String catalog, String schemaPattern, String functionNamePattern) DatabaseMetaData.getFunctionColumns(String, String, String, String)—COLUMN_NAMEper row (function parameter/result columns).static Collection<String>getFunctionColumns(Connection connection, String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) DatabaseMetaData.getFunctionColumns(String, String, String, String)—COLUMN_NAMEper row (function parameter/result columns).static Collection<String>getFunctions(Connection connection) DatabaseMetaData.getFunctions(String, String, String)— qualifiedFUNCTION_SCHEM.FUNCTION_NAMEorFUNCTION_NAME.static Collection<String>getFunctions(Connection connection, String catalog) DatabaseMetaData.getFunctions(String, String, String)— qualifiedFUNCTION_SCHEM.FUNCTION_NAMEorFUNCTION_NAME.static Collection<String>getFunctions(Connection connection, String catalog, String schemaPattern) DatabaseMetaData.getFunctions(String, String, String)— qualifiedFUNCTION_SCHEM.FUNCTION_NAMEorFUNCTION_NAME.static Collection<String>getFunctions(Connection connection, String catalog, String schemaPattern, String functionNamePattern) DatabaseMetaData.getFunctions(String, String, String)— qualifiedFUNCTION_SCHEM.FUNCTION_NAMEorFUNCTION_NAME.static Collection<String>getImportedKeys(Connection connection, String table) DatabaseMetaData.getImportedKeys(String, String, String)— localFKCOLUMN_NAMEvalues.static Collection<String>getImportedKeys(Connection connection, String catalog, String table) DatabaseMetaData.getImportedKeys(String, String, String)— localFKCOLUMN_NAMEvalues.static Collection<String>getImportedKeys(Connection connection, String catalog, String schema, String table) DatabaseMetaData.getImportedKeys(String, String, String)— localFKCOLUMN_NAMEvalues.static Collection<String>getIndexInfo(Connection connection, String table) DatabaseMetaData.getIndexInfo(String, String, String, boolean, boolean)—INDEX_NAME(unique=false,approximate=false).static Collection<String>getIndexInfo(Connection connection, String catalog, String table) DatabaseMetaData.getIndexInfo(String, String, String, boolean, boolean)—INDEX_NAME(unique=false,approximate=false).static Collection<String>getIndexInfo(Connection connection, String catalog, String schema, String table) DatabaseMetaData.getIndexInfo(String, String, String, boolean, boolean)—INDEX_NAME(unique=false,approximate=false).static Collection<String>getIndexInfo(Connection connection, String catalog, String schema, String table, boolean unique, boolean approximate) static Collection<String>getPrimaryKeys(Connection connection, String table) DatabaseMetaData.getPrimaryKeys(String, String, String)—COLUMN_NAMEin JDBC key-sequence order.static Collection<String>getPrimaryKeys(Connection connection, String catalog, String table) DatabaseMetaData.getPrimaryKeys(String, String, String)—COLUMN_NAMEin JDBC key-sequence order.static Collection<String>getPrimaryKeys(Connection connection, String catalog, String schema, String table) DatabaseMetaData.getPrimaryKeys(String, String, String)—COLUMN_NAMEin JDBC key-sequence order.static Collection<String>getProcedureColumns(Connection connection, String procedureNamePattern) DatabaseMetaData.getProcedureColumns(String, String, String, String)—COLUMN_NAMEper row (procedure parameter/result columns).static Collection<String>getProcedureColumns(Connection connection, String catalog, String procedureNamePattern) DatabaseMetaData.getProcedureColumns(String, String, String, String)—COLUMN_NAMEper row (procedure parameter/result columns).static Collection<String>getProcedureColumns(Connection connection, String catalog, String schemaPattern, String procedureNamePattern) DatabaseMetaData.getProcedureColumns(String, String, String, String)—COLUMN_NAMEper row (procedure parameter/result columns).static Collection<String>getProcedureColumns(Connection connection, String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) DatabaseMetaData.getProcedureColumns(String, String, String, String)—COLUMN_NAMEper row (procedure parameter/result columns).static Collection<String>getProcedures(Connection connection) DatabaseMetaData.getProcedures(String, String, String)— qualifiedPROCEDURE_SCHEM.PROCEDURE_NAMEorPROCEDURE_NAME.static Collection<String>getProcedures(Connection connection, String catalog) DatabaseMetaData.getProcedures(String, String, String)— qualifiedPROCEDURE_SCHEM.PROCEDURE_NAMEorPROCEDURE_NAME.static Collection<String>getProcedures(Connection connection, String catalog, String schemaPattern) DatabaseMetaData.getProcedures(String, String, String)— qualifiedPROCEDURE_SCHEM.PROCEDURE_NAMEorPROCEDURE_NAME.static Collection<String>getProcedures(Connection connection, String catalog, String schemaPattern, String procedureNamePattern) DatabaseMetaData.getProcedures(String, String, String)— qualifiedPROCEDURE_SCHEM.PROCEDURE_NAMEorPROCEDURE_NAME.static Collection<String>getSchemas(Connection connection) DatabaseMetaData.getSchemas()—TABLE_CATALOG.TABLE_SCHEMwhen catalog is present, elseTABLE_SCHEM.static Collection<String>getSchemas(Connection connection, String catalog) DatabaseMetaData.getSchemas(String, String)—TABLE_CATALOG.TABLE_SCHEMwhen catalog is present, elseTABLE_SCHEM.static Collection<String>getSchemas(Connection connection, String catalog, String schemaPattern) DatabaseMetaData.getSchemas(String, String)—TABLE_CATALOG.TABLE_SCHEMwhen catalog is present, elseTABLE_SCHEM.static Collection<String>getTables(Connection connection) static Collection<String>getTables(Connection connection, String catalog) static Collection<String>getTables(Connection connection, String catalog, String schemaPattern) static Collection<String>getTables(Connection connection, String catalog, String schemaPattern, String tableNamePattern) static Collection<String>getTablesAndViews(Connection connection) static Collection<String>getTablesAndViews(Connection connection, String catalog) static Collection<String>getTablesAndViews(Connection connection, String catalog, String schemaPattern) static Collection<String>getTablesAndViews(Connection connection, String catalog, String schemaPattern, String tableNamePattern) static Collection<String>getViews(Connection connection) static Collection<String>getViews(Connection connection, String catalog) static Collection<String>getViews(Connection connection, String catalog, String schemaPattern) static Collection<String>getViews(Connection connection, String catalog, String schemaPattern, String tableNamePattern)
-
Constructor Details
-
DatabaseMetaDataUtils
public DatabaseMetaDataUtils()
-
-
Method Details
-
getTables
- Throws:
SQLException
-
getTables
public static Collection<String> getTables(Connection connection, String catalog) throws SQLException - Throws:
SQLException
-
getTables
public static Collection<String> getTables(Connection connection, String catalog, String schemaPattern) throws SQLException - Throws:
SQLException
-
getTables
public static Collection<String> getTables(Connection connection, String catalog, String schemaPattern, String tableNamePattern) throws SQLException - Throws:
SQLException
-
getViews
- Throws:
SQLException
-
getViews
public static Collection<String> getViews(Connection connection, String catalog) throws SQLException - Throws:
SQLException
-
getViews
public static Collection<String> getViews(Connection connection, String catalog, String schemaPattern) throws SQLException - Throws:
SQLException
-
getViews
public static Collection<String> getViews(Connection connection, String catalog, String schemaPattern, String tableNamePattern) throws SQLException - Throws:
SQLException
-
getTablesAndViews
- Throws:
SQLException
-
getTablesAndViews
public static Collection<String> getTablesAndViews(Connection connection, String catalog) throws SQLException - Throws:
SQLException
-
getTablesAndViews
public static Collection<String> getTablesAndViews(Connection connection, String catalog, String schemaPattern) throws SQLException - Throws:
SQLException
-
getTablesAndViews
public static Collection<String> getTablesAndViews(Connection connection, String catalog, String schemaPattern, String tableNamePattern) throws SQLException - Throws:
SQLException
-
getColumns
public static Collection<String> getColumns(Connection connection, String tableName) throws SQLException DatabaseMetaData.getColumns(String, String, String, String)—COLUMN_NAMEvalues.- Throws:
SQLException
-
getColumns
public static Collection<String> getColumns(Connection connection, String catalog, String tableName) throws SQLException DatabaseMetaData.getColumns(String, String, String, String)—COLUMN_NAMEvalues.- Throws:
SQLException
-
getColumns
public static Collection<String> getColumns(Connection connection, String catalog, String schemaPattern, String tableName) throws SQLException DatabaseMetaData.getColumns(String, String, String, String)—COLUMN_NAMEvalues.- Throws:
SQLException
-
getColumns
public static Collection<String> getColumns(Connection connection, String catalog, String schemaPattern, String tableName, String columnNamePattern) throws SQLException DatabaseMetaData.getColumns(String, String, String, String)—COLUMN_NAMEvalues.- Throws:
SQLException
-
getCatalogs
DatabaseMetaData.getCatalogs()—TABLE_CATvalues.- Throws:
SQLException
-
getSchemas
DatabaseMetaData.getSchemas()—TABLE_CATALOG.TABLE_SCHEMwhen catalog is present, elseTABLE_SCHEM.- Throws:
SQLException
-
getSchemas
public static Collection<String> getSchemas(Connection connection, String catalog) throws SQLException DatabaseMetaData.getSchemas(String, String)—TABLE_CATALOG.TABLE_SCHEMwhen catalog is present, elseTABLE_SCHEM.- Throws:
SQLException
-
getSchemas
public static Collection<String> getSchemas(Connection connection, String catalog, String schemaPattern) throws SQLException DatabaseMetaData.getSchemas(String, String)—TABLE_CATALOG.TABLE_SCHEMwhen catalog is present, elseTABLE_SCHEM.- Throws:
SQLException
-
getFunctions
DatabaseMetaData.getFunctions(String, String, String)— qualifiedFUNCTION_SCHEM.FUNCTION_NAMEorFUNCTION_NAME.- Throws:
SQLException
-
getFunctions
public static Collection<String> getFunctions(Connection connection, String catalog) throws SQLException DatabaseMetaData.getFunctions(String, String, String)— qualifiedFUNCTION_SCHEM.FUNCTION_NAMEorFUNCTION_NAME.- Throws:
SQLException
-
getFunctions
public static Collection<String> getFunctions(Connection connection, String catalog, String schemaPattern) throws SQLException DatabaseMetaData.getFunctions(String, String, String)— qualifiedFUNCTION_SCHEM.FUNCTION_NAMEorFUNCTION_NAME.- Throws:
SQLException
-
getFunctions
public static Collection<String> getFunctions(Connection connection, String catalog, String schemaPattern, String functionNamePattern) throws SQLException DatabaseMetaData.getFunctions(String, String, String)— qualifiedFUNCTION_SCHEM.FUNCTION_NAMEorFUNCTION_NAME.- Throws:
SQLException
-
getFunctionColumns
public static Collection<String> getFunctionColumns(Connection connection, String functionNamePattern) throws SQLException DatabaseMetaData.getFunctionColumns(String, String, String, String)—COLUMN_NAMEper row (function parameter/result columns).- Throws:
SQLException
-
getFunctionColumns
public static Collection<String> getFunctionColumns(Connection connection, String catalog, String functionNamePattern) throws SQLException DatabaseMetaData.getFunctionColumns(String, String, String, String)—COLUMN_NAMEper row (function parameter/result columns).- Throws:
SQLException
-
getFunctionColumns
public static Collection<String> getFunctionColumns(Connection connection, String catalog, String schemaPattern, String functionNamePattern) throws SQLException DatabaseMetaData.getFunctionColumns(String, String, String, String)—COLUMN_NAMEper row (function parameter/result columns).- Throws:
SQLException
-
getFunctionColumns
public static Collection<String> getFunctionColumns(Connection connection, String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException DatabaseMetaData.getFunctionColumns(String, String, String, String)—COLUMN_NAMEper row (function parameter/result columns).- Throws:
SQLException
-
getProcedures
DatabaseMetaData.getProcedures(String, String, String)— qualifiedPROCEDURE_SCHEM.PROCEDURE_NAMEorPROCEDURE_NAME.- Throws:
SQLException
-
getProcedures
public static Collection<String> getProcedures(Connection connection, String catalog) throws SQLException DatabaseMetaData.getProcedures(String, String, String)— qualifiedPROCEDURE_SCHEM.PROCEDURE_NAMEorPROCEDURE_NAME.- Throws:
SQLException
-
getProcedures
public static Collection<String> getProcedures(Connection connection, String catalog, String schemaPattern) throws SQLException DatabaseMetaData.getProcedures(String, String, String)— qualifiedPROCEDURE_SCHEM.PROCEDURE_NAMEorPROCEDURE_NAME.- Throws:
SQLException
-
getProcedures
public static Collection<String> getProcedures(Connection connection, String catalog, String schemaPattern, String procedureNamePattern) throws SQLException DatabaseMetaData.getProcedures(String, String, String)— qualifiedPROCEDURE_SCHEM.PROCEDURE_NAMEorPROCEDURE_NAME.- Throws:
SQLException
-
getProcedureColumns
public static Collection<String> getProcedureColumns(Connection connection, String procedureNamePattern) throws SQLException DatabaseMetaData.getProcedureColumns(String, String, String, String)—COLUMN_NAMEper row (procedure parameter/result columns).- Throws:
SQLException
-
getProcedureColumns
public static Collection<String> getProcedureColumns(Connection connection, String catalog, String procedureNamePattern) throws SQLException DatabaseMetaData.getProcedureColumns(String, String, String, String)—COLUMN_NAMEper row (procedure parameter/result columns).- Throws:
SQLException
-
getProcedureColumns
public static Collection<String> getProcedureColumns(Connection connection, String catalog, String schemaPattern, String procedureNamePattern) throws SQLException DatabaseMetaData.getProcedureColumns(String, String, String, String)—COLUMN_NAMEper row (procedure parameter/result columns).- Throws:
SQLException
-
getProcedureColumns
public static Collection<String> getProcedureColumns(Connection connection, String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException DatabaseMetaData.getProcedureColumns(String, String, String, String)—COLUMN_NAMEper row (procedure parameter/result columns).- Throws:
SQLException
-
getPrimaryKeys
public static Collection<String> getPrimaryKeys(Connection connection, String table) throws SQLException DatabaseMetaData.getPrimaryKeys(String, String, String)—COLUMN_NAMEin JDBC key-sequence order.- Throws:
SQLException
-
getPrimaryKeys
public static Collection<String> getPrimaryKeys(Connection connection, String catalog, String table) throws SQLException DatabaseMetaData.getPrimaryKeys(String, String, String)—COLUMN_NAMEin JDBC key-sequence order.- Throws:
SQLException
-
getPrimaryKeys
public static Collection<String> getPrimaryKeys(Connection connection, String catalog, String schema, String table) throws SQLException DatabaseMetaData.getPrimaryKeys(String, String, String)—COLUMN_NAMEin JDBC key-sequence order.- Throws:
SQLException
-
getImportedKeys
public static Collection<String> getImportedKeys(Connection connection, String table) throws SQLException DatabaseMetaData.getImportedKeys(String, String, String)— localFKCOLUMN_NAMEvalues.- Throws:
SQLException
-
getImportedKeys
public static Collection<String> getImportedKeys(Connection connection, String catalog, String table) throws SQLException DatabaseMetaData.getImportedKeys(String, String, String)— localFKCOLUMN_NAMEvalues.- Throws:
SQLException
-
getImportedKeys
public static Collection<String> getImportedKeys(Connection connection, String catalog, String schema, String table) throws SQLException DatabaseMetaData.getImportedKeys(String, String, String)— localFKCOLUMN_NAMEvalues.- Throws:
SQLException
-
getExportedKeys
public static Collection<String> getExportedKeys(Connection connection, String table) throws SQLException DatabaseMetaData.getExportedKeys(String, String, String)—PKCOLUMN_NAMEon this table as referenced primary key.- Throws:
SQLException
-
getExportedKeys
public static Collection<String> getExportedKeys(Connection connection, String catalog, String table) throws SQLException DatabaseMetaData.getExportedKeys(String, String, String)—PKCOLUMN_NAMEon this table as referenced primary key.- Throws:
SQLException
-
getExportedKeys
public static Collection<String> getExportedKeys(Connection connection, String catalog, String schema, String table) throws SQLException DatabaseMetaData.getExportedKeys(String, String, String)—PKCOLUMN_NAMEon this table as referenced primary key.- Throws:
SQLException
-
getIndexInfo
public static Collection<String> getIndexInfo(Connection connection, String table) throws SQLException DatabaseMetaData.getIndexInfo(String, String, String, boolean, boolean)—INDEX_NAME(unique=false,approximate=false).- Throws:
SQLException
-
getIndexInfo
public static Collection<String> getIndexInfo(Connection connection, String catalog, String table) throws SQLException DatabaseMetaData.getIndexInfo(String, String, String, boolean, boolean)—INDEX_NAME(unique=false,approximate=false).- Throws:
SQLException
-
getIndexInfo
public static Collection<String> getIndexInfo(Connection connection, String catalog, String schema, String table) throws SQLException DatabaseMetaData.getIndexInfo(String, String, String, boolean, boolean)—INDEX_NAME(unique=false,approximate=false).- Throws:
SQLException
-
getIndexInfo
public static Collection<String> getIndexInfo(Connection connection, String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException - Throws:
SQLException
-