Class DatabaseMetadataHelper
java.lang.Object
org.eclipse.dirigible.databases.helpers.DatabaseMetadataHelper
public class DatabaseMetadataHelper extends Object
The Database Metadata Helper.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDatabaseMetadataHelper.ColumnsIteratorCallbackThe Interface ColumnsIteratorCallback.static interfaceDatabaseMetadataHelper.Filter<T>The Interface Filter.static interfaceDatabaseMetadataHelper.FunctionColumnsIteratorCallbackThe Interface FunctionColumnsIteratorCallback.static interfaceDatabaseMetadataHelper.IndicesIteratorCallbackThe Interface IndicesIteratorCallback.static interfaceDatabaseMetadataHelper.ProcedureColumnsIteratorCallbackThe Interface ProceduresColumnsIteratorCallback. -
Field Summary
Fields Modifier and Type Field Description static StringDECIMAL_DIGITSThe Constant DECIMAL_DIGITS. -
Constructor Summary
Constructors Constructor Description DatabaseMetadataHelper() -
Method Summary
Modifier and Type Method Description static FunctionMetadatadescribeFunction(Connection connection, String catalogName, String schemeName, String functionName)Describe function.static ProcedureMetadatadescribeProcedure(Connection connection, String catalogName, String schemeName, String procedureName)Describe procedure.static TableMetadatadescribeTable(Connection connection, String catalogName, String schemeName, String tableName)Describe table.static StringgetFunctionMetadataAsJson(DataSource dataSource, String schema, String function)Gets the metadata as json.static StringgetMetadataAsJson(DataSource dataSource)Gets the metadata as json.static StringgetProcedureMetadataAsJson(DataSource dataSource, String schema, String procedure)Gets the metadata as json.static StringgetProductName(DataSource dataSource)Gets the product name.static StringgetTableMetadataAsJson(DataSource dataSource, String schema, String table)Gets the metadata as json.static voiditerateFunctionDefinition(Connection connection, String catalogName, String schemaName, String functionName, DatabaseMetadataHelper.FunctionColumnsIteratorCallback functionColumnsIteratorCallback)Iterate function definition.static voiditerateProcedureDefinition(Connection connection, String catalogName, String schemaName, String procedureName, DatabaseMetadataHelper.ProcedureColumnsIteratorCallback procedureColumnsIteratorCallback)Iterate procedure definition.static voiditerateTableDefinition(Connection connection, String catalogName, String schemaName, String tableName, DatabaseMetadataHelper.ColumnsIteratorCallback columnsIteratorCallback, DatabaseMetadataHelper.IndicesIteratorCallback indicesIteratorCallback)Iterate table definition.static List<FunctionMetadata>listFunctions(Connection connection, String catalogName, String schemeName, DatabaseMetadataHelper.Filter<String> functionNameFilter)List functions.static List<ProcedureMetadata>listProcedures(Connection connection, String catalogName, String schemeName, DatabaseMetadataHelper.Filter<String> procedureNameFilter)List procedures.static List<SchemaMetadata>listSchemas(Connection connection, String catalogName, DatabaseMetadataHelper.Filter<String> schemaNameFilter, DatabaseMetadataHelper.Filter<String> nameFilter)List schemas.static List<TableMetadata>listTables(Connection connection, String catalogName, String schemeName, DatabaseMetadataHelper.Filter<String> tableNameFilter)List tables.static StringnormalizeTableName(String table)Makes necessary formatting if needed.
-
Field Details
-
DECIMAL_DIGITS
The Constant DECIMAL_DIGITS.- See Also:
- Constant Field Values
-
-
Constructor Details
-
DatabaseMetadataHelper
public DatabaseMetadataHelper()
-
-
Method Details
-
listSchemas
public static List<SchemaMetadata> listSchemas(Connection connection, String catalogName, DatabaseMetadataHelper.Filter<String> schemaNameFilter, DatabaseMetadataHelper.Filter<String> nameFilter) throws SQLExceptionList schemas.- Parameters:
connection- the connectioncatalogName- the catalog nameschemaNameFilter- the schema name filternameFilter- the name filter- Returns:
- the list
- Throws:
SQLException- the SQL exception
-
listTables
public static List<TableMetadata> listTables(Connection connection, String catalogName, String schemeName, DatabaseMetadataHelper.Filter<String> tableNameFilter) throws SQLExceptionList tables.- Parameters:
connection- the connectioncatalogName- the catalog nameschemeName- the scheme nametableNameFilter- the table name filter- Returns:
- the list
- Throws:
SQLException- the SQL exception
-
listProcedures
public static List<ProcedureMetadata> listProcedures(Connection connection, String catalogName, String schemeName, DatabaseMetadataHelper.Filter<String> procedureNameFilter) throws SQLExceptionList procedures.- Parameters:
connection- the connectioncatalogName- the catalog nameschemeName- the scheme nameprocedureNameFilter- the procedure name filter- Returns:
- the list
- Throws:
SQLException- the SQL exception
-
listFunctions
public static List<FunctionMetadata> listFunctions(Connection connection, String catalogName, String schemeName, DatabaseMetadataHelper.Filter<String> functionNameFilter) throws SQLExceptionList functions.- Parameters:
connection- the connectioncatalogName- the catalog nameschemeName- the scheme namefunctionNameFilter- the function name filter- Returns:
- the list
- Throws:
SQLException- the SQL exception
-
describeTable
public static TableMetadata describeTable(Connection connection, String catalogName, String schemeName, String tableName) throws SQLExceptionDescribe table.- Parameters:
connection- the connectioncatalogName- the catalog nameschemeName- the scheme nametableName- the table name- Returns:
- the TableMetadata
- Throws:
SQLException- the SQL exception
-
describeProcedure
public static ProcedureMetadata describeProcedure(Connection connection, String catalogName, String schemeName, String procedureName) throws SQLExceptionDescribe procedure.- Parameters:
connection- the connectioncatalogName- the catalog nameschemeName- the scheme nameprocedureName- the procedure name- Returns:
- the ProcedureMetadata
- Throws:
SQLException- the SQL exception
-
describeFunction
public static FunctionMetadata describeFunction(Connection connection, String catalogName, String schemeName, String functionName) throws SQLExceptionDescribe function.- Parameters:
connection- the connectioncatalogName- the catalog nameschemeName- the scheme namefunctionName- the function name- Returns:
- the FunctionMetadata
- Throws:
SQLException- the SQL exception
-
iterateTableDefinition
public static void iterateTableDefinition(Connection connection, String catalogName, String schemaName, String tableName, DatabaseMetadataHelper.ColumnsIteratorCallback columnsIteratorCallback, DatabaseMetadataHelper.IndicesIteratorCallback indicesIteratorCallback) throws SQLExceptionIterate table definition.- Parameters:
connection- the connectioncatalogName- the catalog nameschemaName- the schema nametableName- the table namecolumnsIteratorCallback- the columns iterator callbackindicesIteratorCallback- the indices iterator callback- Throws:
SQLException- the SQL exception
-
iterateProcedureDefinition
public static void iterateProcedureDefinition(Connection connection, String catalogName, String schemaName, String procedureName, DatabaseMetadataHelper.ProcedureColumnsIteratorCallback procedureColumnsIteratorCallback) throws SQLExceptionIterate procedure definition.- Parameters:
connection- the connectioncatalogName- the catalog nameschemaName- the schema nameprocedureName- the procedure nameprocedureColumnsIteratorCallback- the procedure columns iterator callback- Throws:
SQLException- the SQL exception
-
iterateFunctionDefinition
public static void iterateFunctionDefinition(Connection connection, String catalogName, String schemaName, String functionName, DatabaseMetadataHelper.FunctionColumnsIteratorCallback functionColumnsIteratorCallback) throws SQLExceptionIterate function definition.- Parameters:
connection- the connectioncatalogName- the catalog nameschemaName- the schema namefunctionName- the function namefunctionColumnsIteratorCallback- the function columns iterator callback- Throws:
SQLException- the SQL exception
-
getMetadataAsJson
Gets the metadata as json.- Parameters:
dataSource- the data source- Returns:
- the metadata as json
- Throws:
SQLException- the SQL exception
-
getTableMetadataAsJson
public static String getTableMetadataAsJson(DataSource dataSource, String schema, String table) throws SQLExceptionGets the metadata as json.- Parameters:
dataSource- the data sourceschema- the schema nametable- the table name- Returns:
- the metadata as json
- Throws:
SQLException- the SQL exception
-
getProcedureMetadataAsJson
public static String getProcedureMetadataAsJson(DataSource dataSource, String schema, String procedure) throws SQLExceptionGets the metadata as json.- Parameters:
dataSource- the data sourceschema- the schema nameprocedure- the procedure name- Returns:
- the metadata as json
- Throws:
SQLException- the SQL exception
-
getFunctionMetadataAsJson
public static String getFunctionMetadataAsJson(DataSource dataSource, String schema, String function) throws SQLExceptionGets the metadata as json.- Parameters:
dataSource- the data sourceschema- the schema namefunction- the function name- Returns:
- the metadata as json
- Throws:
SQLException- the SQL exception
-
getProductName
Gets the product name.- Parameters:
dataSource- the data source- Returns:
- the product name
- Throws:
SQLException- the SQL exception
-
normalizeTableName
Makes necessary formatting if needed.- Parameters:
table- the table name- Returns:
- the formatted table name
-