|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.intermine.sql.DatabaseUtil
public final class DatabaseUtil
Collection of commonly used Database utilities
| Method Summary | |
|---|---|
static void |
analyse(Database db,
boolean full)
Analyse given database, perform vacuum full analyse if full parameter true. |
static void |
analyse(Database db,
ClassDescriptor cld,
boolean full)
Analyse database table for a given class and all associated indirection tables. |
static void |
createBagTable(Database db,
java.sql.Connection con,
java.lang.String tableName,
java.util.Collection<?> bag,
java.lang.Class<?> c)
Create a new table the holds the contents of the given Collection (bag). |
static java.lang.String |
generateSqlCompatibleName(java.lang.String n)
Convert any sql keywords to valid names for tables/columns. |
static java.lang.String |
getColumnName(FieldDescriptor fd)
Creates a column name for a field descriptor |
static java.lang.String |
getIndirectionTableName(CollectionDescriptor col)
Creates an indirection table name for a many-to-many collection descriptor |
static java.util.Set<java.lang.String> |
getIndirectionTableNames(ClassDescriptor cld)
Given a ClassDescriptor find names of all related indirection tables. |
static java.lang.String |
getInwardIndirectionColumnName(CollectionDescriptor col,
int version)
Creates a column name for the "inward" key of a many-to-many collection descriptor. |
static java.lang.String |
getOutwardIndirectionColumnName(CollectionDescriptor col,
int version)
Creates a column name for the "outward" key of a many-to-many collection descriptor. |
static java.lang.String |
getTableName(ClassDescriptor cld)
Creates a table name for a class descriptor |
static void |
grant(Database db,
java.lang.String user,
java.lang.String perm)
Grant permission on all tables for given user on specified database. |
static java.lang.String |
objectToString(java.lang.Object o)
Generate an SQL compatible representation of an object. |
static void |
removeAllTables(java.sql.Connection con)
Removes every single table from the database given. |
static boolean |
tableExists(java.sql.Connection con,
java.lang.String tableName)
Tests if a table exists in the database |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean tableExists(java.sql.Connection con,
java.lang.String tableName)
throws java.sql.SQLException
con - a connection to a databasetableName - the name of a table to test for
java.sql.SQLException - if an error occurs in the underlying database
java.lang.NullPointerException - if tableName is null
public static void removeAllTables(java.sql.Connection con)
throws java.sql.SQLException
con - the Connection to the database
java.sql.SQLException - if an error occurs in the underlying databasepublic static java.lang.String getTableName(ClassDescriptor cld)
cld - ClassDescriptor
public static java.lang.String getColumnName(FieldDescriptor fd)
fd - FieldDescriptor
public static java.lang.String getIndirectionTableName(CollectionDescriptor col)
col - CollectionDescriptor
public static java.lang.String getInwardIndirectionColumnName(CollectionDescriptor col,
int version)
col - CollectionDescriptorversion - the database version number
public static java.lang.String getOutwardIndirectionColumnName(CollectionDescriptor col,
int version)
col - CollectionDescriptorversion - the database version number
public static java.lang.String generateSqlCompatibleName(java.lang.String n)
n - the string to convert
public static java.lang.String objectToString(java.lang.Object o)
o - the Object
java.lang.IllegalArgumentException - if the object is not representable
public static void analyse(Database db,
boolean full)
throws java.sql.SQLException
db - the database to analysefull - if true perform VACUUM FULL ANALYSE
java.sql.SQLException - if db problem
public static void analyse(Database db,
ClassDescriptor cld,
boolean full)
throws java.sql.SQLException
db - the database to analysecld - description of class to analysefull - if true perform VACUUM FULL ANALYSE
java.sql.SQLException - if db problempublic static java.util.Set<java.lang.String> getIndirectionTableNames(ClassDescriptor cld)
cld - class to find tables for
public static void grant(Database db,
java.lang.String user,
java.lang.String perm)
throws java.sql.SQLException
db - the database to grant permissions onuser - the username to grant permission toperm - permission to grant
java.sql.SQLException - if db problem
public static void createBagTable(Database db,
java.sql.Connection con,
java.lang.String tableName,
java.util.Collection<?> bag,
java.lang.Class<?> c)
throws java.sql.SQLException
db - the Database to accesscon - the Connection to usetableName - the name to use for the new tablebag - the Collection to create a table forc - the type of objects to put in the new table
java.sql.SQLException - if there is a database problem
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||