Package adams.db
Class JDBC
- java.lang.Object
-
- adams.db.JDBC
-
public class JDBC extends Object
Utility class for JDBC.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static String
URL_H2
the expression to match an H2 JDBC URL.static String
URL_HSQLDB
the expression to match a HSQLDB JDBC URL.static String
URL_MSSQL
the expression to match a MSSQL JDBC URL.static String
URL_MYSQL
the expression to match a MySQL JDBC URL.static String
URL_POSTGRESQL
the expression to match a PostgreSQL JDBC URL.static String
URL_SQLITE
the expression to match a SQLite JDBC URL.
-
Constructor Summary
Constructors Constructor Description JDBC()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getDefaultTimestamp(AbstractDatabaseConnection conn)
Returns the default timestamp to use for the URL.static String
getDefaultTimestamp(String url)
Returns the default timestamp to use for the URL.static AbstractDatabaseQueries
getQueries(AbstractDatabaseConnection conn)
Returns the appropriate queries helper.static AbstractDatabaseQueries
getQueries(String url)
Returns the appropriate queries helper.static AbstractDatabaseQuirks
getQuirks(AbstractDatabaseConnection conn)
Returns the appropriate quirks.static AbstractDatabaseQuirks
getQuirks(String url)
Returns the appropriate quirks.static AbstractTypes
getTypes(AbstractDatabaseConnection conn)
Returns the appropriate types.static AbstractTypes
getTypes(String url)
Returns the appropriate types.static boolean
isH2(AbstractDatabaseConnection conn)
Checks whether this connection represents a H2 one.static boolean
isH2(String url)
Checks whether this JDBC url represents a H2 URL.static boolean
isHSQLDB(AbstractDatabaseConnection conn)
Checks whether this connection represents a HSQLDB one.static boolean
isHSQLDB(String url)
Checks whether this JDBC url represents a HSQLDB URL.static boolean
isMSSQL(AbstractDatabaseConnection conn)
Checks whether this connection represents a MSSQL one.static boolean
isMSSQL(String url)
Checks whether this JDBC url represents a MSSQL URL.static boolean
isMySQL(AbstractDatabaseConnection conn)
Checks whether this connection represents a MySQL one.static boolean
isMySQL(String url)
Checks whether this JDBC url represents a MySQL URL.static boolean
isPostgreSQL(AbstractDatabaseConnection conn)
Checks whether this connection represents a PostgreSQL one.static boolean
isPostgreSQL(String url)
Checks whether this JDBC url represents a PostgreSQL URL.static boolean
isSQLite(AbstractDatabaseConnection conn)
Checks whether this connection represents a SQLite one.static boolean
isSQLite(String url)
Checks whether this JDBC url represents a SQLite URL.
-
-
-
Field Detail
-
URL_MYSQL
public static final String URL_MYSQL
the expression to match a MySQL JDBC URL.- See Also:
- Constant Field Values
-
URL_POSTGRESQL
public static final String URL_POSTGRESQL
the expression to match a PostgreSQL JDBC URL.- See Also:
- Constant Field Values
-
URL_SQLITE
public static final String URL_SQLITE
the expression to match a SQLite JDBC URL.- See Also:
- Constant Field Values
-
URL_HSQLDB
public static final String URL_HSQLDB
the expression to match a HSQLDB JDBC URL.- See Also:
- Constant Field Values
-
URL_H2
public static final String URL_H2
the expression to match an H2 JDBC URL.- See Also:
- Constant Field Values
-
URL_MSSQL
public static final String URL_MSSQL
the expression to match a MSSQL JDBC URL.- See Also:
- Constant Field Values
-
-
Method Detail
-
isMySQL
public static boolean isMySQL(String url)
Checks whether this JDBC url represents a MySQL URL.- Parameters:
url
- the URL to check- Returns:
- true if MySQL URL
- See Also:
URL_MYSQL
-
isMySQL
public static boolean isMySQL(AbstractDatabaseConnection conn)
Checks whether this connection represents a MySQL one.- Parameters:
conn
- the connection to check- Returns:
- true if MySQL URL
- See Also:
isMySQL(String)
-
isPostgreSQL
public static boolean isPostgreSQL(String url)
Checks whether this JDBC url represents a PostgreSQL URL.- Parameters:
url
- the URL to check- Returns:
- true if PostgreSQL URL
- See Also:
URL_POSTGRESQL
-
isPostgreSQL
public static boolean isPostgreSQL(AbstractDatabaseConnection conn)
Checks whether this connection represents a PostgreSQL one.- Parameters:
conn
- the connection to check- Returns:
- true if PostgreSQL URL
- See Also:
isPostgreSQL(String)
-
isSQLite
public static boolean isSQLite(String url)
Checks whether this JDBC url represents a SQLite URL.- Parameters:
url
- the URL to check- Returns:
- true if SQLite URL
- See Also:
URL_SQLITE
-
isSQLite
public static boolean isSQLite(AbstractDatabaseConnection conn)
Checks whether this connection represents a SQLite one.- Parameters:
conn
- the connection to check- Returns:
- true if SQLite URL
- See Also:
isSQLite(String)
-
isH2
public static boolean isH2(String url)
Checks whether this JDBC url represents a H2 URL.- Parameters:
url
- the URL to check- Returns:
- true if H2 URL
- See Also:
URL_H2
-
isH2
public static boolean isH2(AbstractDatabaseConnection conn)
Checks whether this connection represents a H2 one.- Parameters:
conn
- the connection to check- Returns:
- true if h2 URL
- See Also:
isH2(String)
-
isHSQLDB
public static boolean isHSQLDB(String url)
Checks whether this JDBC url represents a HSQLDB URL.- Parameters:
url
- the URL to check- Returns:
- true if HSQLDB URL
- See Also:
URL_HSQLDB
-
isHSQLDB
public static boolean isHSQLDB(AbstractDatabaseConnection conn)
Checks whether this connection represents a HSQLDB one.- Parameters:
conn
- the connection to check- Returns:
- true if HSQLDB URL
- See Also:
isHSQLDB(String)
-
isMSSQL
public static boolean isMSSQL(String url)
Checks whether this JDBC url represents a MSSQL URL.- Parameters:
url
- the URL to check- Returns:
- true if MSSQL URL
- See Also:
URL_MSSQL
-
isMSSQL
public static boolean isMSSQL(AbstractDatabaseConnection conn)
Checks whether this connection represents a MSSQL one.- Parameters:
conn
- the connection to check- Returns:
- true if MSSQL URL
- See Also:
isMSSQL(String)
-
getTypes
public static AbstractTypes getTypes(AbstractDatabaseConnection conn)
Returns the appropriate types.- Parameters:
conn
- the connection to use for identification- Returns:
- the types
- Throws:
IllegalArgumentException
- if JDBC connection type not supported
-
getTypes
public static AbstractTypes getTypes(String url)
Returns the appropriate types.- Parameters:
url
- the URL to use for identification- Returns:
- the types
- Throws:
IllegalArgumentException
- if JDBC connection type not supported
-
getQuirks
public static AbstractDatabaseQuirks getQuirks(AbstractDatabaseConnection conn)
Returns the appropriate quirks.- Parameters:
conn
- the connection to use for identification- Returns:
- the quirks
- Throws:
IllegalArgumentException
- if JDBC connection type not supported
-
getQuirks
public static AbstractDatabaseQuirks getQuirks(String url)
Returns the appropriate quirks.- Parameters:
url
- the URL to use for identification- Returns:
- the quirks
- Throws:
IllegalArgumentException
- if JDBC connection type not supported
-
getQueries
public static AbstractDatabaseQueries getQueries(AbstractDatabaseConnection conn)
Returns the appropriate queries helper.- Parameters:
conn
- the connection to use for identification- Returns:
- the queries helper
- Throws:
IllegalArgumentException
- if JDBC connection type not supported
-
getQueries
public static AbstractDatabaseQueries getQueries(String url)
Returns the appropriate queries helper.- Parameters:
url
- the URL to use for identification- Returns:
- the queries helper
- Throws:
IllegalArgumentException
- if JDBC connection type not supported
-
getDefaultTimestamp
public static String getDefaultTimestamp(AbstractDatabaseConnection conn)
Returns the default timestamp to use for the URL. Defaults toConstants.TIMESTAMP_DEFAULT_MYSQL
.- Parameters:
conn
- the connection to use for identification- Returns:
- the default timestamp value
- Throws:
IllegalArgumentException
- if JDBC connection type not supported
-
getDefaultTimestamp
public static String getDefaultTimestamp(String url)
Returns the default timestamp to use for the URL. Defaults toConstants.TIMESTAMP_DEFAULT_MYSQL
.- Parameters:
url
- the URL to use for identification- Returns:
- the default timestamp value
- Throws:
IllegalArgumentException
- if JDBC connection type not supported
-
-