Class DatabaseUtil
- java.lang.Object
-
- com.identityworksllc.iiq.common.query.DatabaseUtil
-
public class DatabaseUtil extends Object
Utility class for database operations
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDatabaseUtil.DatabaseTypeRepresents the type of a database
-
Field Summary
Fields Modifier and Type Field Description static Set<String>RESERVED_SQL_WORDSSet of reserved SQL words
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DatabaseUtil.DatabaseTypegetType(Connection connection)Determines the type of the given databasestatic booleanisMicrosoft(Connection connection)Determines if the given connection is to a Microsoft SQL Server databasestatic booleanisMysql(Connection connection)Determines if the given connection is to a MySQL databasestatic booleanisOracle(Connection connection)Determines if the given connection is to an Oracle databasestatic booleanisPostgres(Connection connection)Determines if the given connection is to a PostgreSQL databasestatic booleanisValidObjectName(String name)Determines if the given name is a valid DB object namestatic booleantableExists(Connection connection, String tableName)Returns true if the given table exists
-
-
-
Field Detail
-
RESERVED_SQL_WORDS
public static final Set<String> RESERVED_SQL_WORDS
Set of reserved SQL words
-
-
Method Detail
-
getType
public static DatabaseUtil.DatabaseType getType(Connection connection) throws SQLException
Determines the type of the given database- Parameters:
connection- The connection to the database- Returns:
- The resulting type determination
- Throws:
SQLException- if type determination fails, or if the DB is not a recognized type
-
isMicrosoft
public static boolean isMicrosoft(Connection connection) throws SQLException
Determines if the given connection is to a Microsoft SQL Server database- Parameters:
connection- The connection to the database- Returns:
- true if the database is Microsoft SQL Server, false otherwise
- Throws:
SQLException- if the database type cannot be determined
-
isMysql
public static boolean isMysql(Connection connection) throws SQLException
Determines if the given connection is to a MySQL database- Parameters:
connection- The connection to the database- Returns:
- true if the database is MySQL, false otherwise
- Throws:
SQLException- if the database type cannot be determined
-
isOracle
public static boolean isOracle(Connection connection) throws SQLException
Determines if the given connection is to an Oracle database- Parameters:
connection- The connection to the database- Returns:
- true if the database is Oracle, false otherwise
- Throws:
SQLException- if the database type cannot be determined
-
isPostgres
public static boolean isPostgres(Connection connection) throws SQLException
Determines if the given connection is to a PostgreSQL database- Parameters:
connection- The connection to the database- Returns:
- true if the database is PostgreSQL, false otherwise
- Throws:
SQLException- if the database type cannot be determined
-
isValidObjectName
public static boolean isValidObjectName(String name)
Determines if the given name is a valid DB object name- Parameters:
name- The name to check- Returns:
- true if the name is a valid object name, false otherwise
-
tableExists
public static boolean tableExists(Connection connection, String tableName)
Returns true if the given table exists- Parameters:
connection- The connection to the databasetableName- The name of the table to check- Returns:
- true if the table exists, false otherwise
-
-