public class JDBCUtilities extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JDBCUtilities.FUNCTION_TYPE |
| Modifier and Type | Field and Description |
|---|---|
static String |
H2_DRIVER_NAME |
| Modifier and Type | Method and Description |
|---|---|
static PropertyChangeListener |
attachCancelResultSet(Statement st,
org.h2gis.api.ProgressVisitor progressVisitor) |
static int |
getFieldIndex(ResultSetMetaData resultSetMetaData,
String fieldName)
Fetch the metadata, and check field name
|
static String |
getFieldName(DatabaseMetaData meta,
String table,
int fieldIndex) |
static List<String> |
getFieldNames(DatabaseMetaData meta,
String table)
Returns the list of all the field name of a table.
|
static int |
getIntegerPrimaryKey(Connection connection,
String tableReference) |
static int |
getRowCount(Connection connection,
String tableReference)
Fetch the row count of a table.
|
static List<String> |
getTableNames(DatabaseMetaData metaData,
String catalog,
String schemaPattern,
String tableNamePattern,
String[] types)
Returns the list of table names.
|
static List<String> |
getUniqueFieldValues(Connection connection,
String tableName,
String fieldName)
Returns the list of distinct values contained by a field from a table from the database
|
static boolean |
hasField(Connection connection,
String tableName,
String fieldName)
Return true if table tableName contains field fieldName.
|
static boolean |
isH2DataBase(DatabaseMetaData metaData) |
static boolean |
isTemporaryTable(Connection connection,
String tableReference)
Read INFORMATION_SCHEMA.TABLES in order to see if the provided table reference is a temporary table.
|
static boolean |
tableExists(Connection connection,
String tableName)
Return true if the table exists.
|
public static final String H2_DRIVER_NAME
public static boolean hasField(Connection connection, String tableName, String fieldName) throws SQLException
connection - ConnectiontableName - Table namefieldName - Field nameSQLExceptionpublic static int getFieldIndex(ResultSetMetaData resultSetMetaData, String fieldName) throws SQLException
resultSetMetaData - Active result set meta data.fieldName - Field name, ignore caseSQLExceptionpublic static String getFieldName(DatabaseMetaData meta, String table, int fieldIndex) throws SQLException
meta - DataBase meta datatable - Table identifier [[catalog.]schema.]tablefieldIndex - Field ordinal position [1-n]SQLException - If jdbc throws an errorpublic static List<String> getFieldNames(DatabaseMetaData meta, String table) throws SQLException
meta - DataBase meta datatable - Table identifier [[catalog.]schema.]tableSQLException - If jdbc throws an errorpublic static int getRowCount(Connection connection, String tableReference) throws SQLException
connection - Active connection.tableReference - Table referenceSQLException - If the table does not exists, or sql request fail.public static boolean isTemporaryTable(Connection connection, String tableReference) throws SQLException
connection - Active connection not closed by this methodtableReference - Table referenceSQLException - If the table does not exists.public static boolean isH2DataBase(DatabaseMetaData metaData) throws SQLException
metaData - Database meta dataSQLExceptionpublic static int getIntegerPrimaryKey(Connection connection, String tableReference) throws SQLException
connection - ConnectiontableReference - table identifierSQLExceptionpublic static boolean tableExists(Connection connection, String tableName) throws SQLException
connection - ConnectiontableName - Table nameSQLExceptionpublic static List<String> getTableNames(DatabaseMetaData metaData, String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException
metaData - Database meta datacatalog - A catalog name. Must match the catalog name as it is stored in the database.
"" retrieves those without a catalog; null means that the catalog name should not be used to
narrow the searchschemaPattern - A schema name pattern. Must match the schema name as it is stored in the database.
"" retrieves those without a schema.
null means that the schema name should not be used to narrow the searchtableNamePattern - A table name pattern. Must match the table name as it is stored in the databasetypes - A list of table types, which must be from the list of table types returned from getTableTypes(),
to include. null returns all typesSQLExceptionpublic static List<String> getUniqueFieldValues(Connection connection, String tableName, String fieldName) throws SQLException
connection - ConnectiontableName - Name of the table containing the field.fieldName - Name of the field containing the values.SQLExceptionpublic static PropertyChangeListener attachCancelResultSet(Statement st, org.h2gis.api.ProgressVisitor progressVisitor)
st - Statement to cancelprogressVisitor - Progress to link withProgressVisitor.removePropertyChangeListener(java.beans.PropertyChangeListener)
with this object as argumentCopyright © 2017 CNRS. All rights reserved.