Top Inners Fields Constructors Methods
liquibase.database

public Class DatabaseFactory

extends Object
implements SingletonObject
Class Inheritance
All Implemented Interfaces
liquibase.SingletonObject
Imports
liquibase.Scope, .SingletonObject, liquibase.database.core.UnsupportedDatabase, liquibase.database.jvm.JdbcConnection, liquibase.exception.DatabaseException, .UnexpectedLiquibaseException, liquibase.logging.Logger, liquibase.resource.PathHandlerFactory, .Resource, .ResourceAccessor, liquibase.util.StringUtil, .SystemUtil, java.io.IOException, .InputStream, java.lang.reflect.InvocationTargetException, java.sql.Driver, java.util.ArrayList, .Comparator, .HashMap, .List, .Map, .Properties, .SortedSet, .TreeSet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Map<String, SortedSet<Database>>
private static DatabaseFactory
private final Map<String, SortedSet<Database>>
private static final Logger
private Database

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private Properties
buildDriverProperties(String username, String password, String driverPropertiesFile, String propertyProviderClass)

public void
clearRegistry()

Removes all registered databases, even built in ones.

public Database
public String

Returns:

a Database object supporting the URL. May also return null if the JDBC URL is unknown to all handlers.
findDefaultDriver
(String
the JDBC URL to analyse
url
)

Returns the Java class name of the JDBC driver class (e.g. "org.mariadb.jdbc.Driver") for the specified JDBC URL, if any Database class supports that URL.

private String
findDriverClass(String url, String driver, DatabaseFactory databaseFactory)

public Database
getDatabase(String shortName)

public List<Database>
getImplementedDatabases()

Returns instances of all implemented database types.

public static synchronized DatabaseFactory
public List<Database>
getInternalDatabases()

Returns instances of all "internal" database types.

private Driver
loadDriver(String driverClass)

public DatabaseConnection
openConnection(String url, String username, String password, String propertyProvider, ResourceAccessor resourceAccessor)

public DatabaseConnection
openConnection(String url, String username, String password, String driver, String databaseClass, String driverPropertiesFile, String propertyProviderClass, ResourceAccessor resourceAccessor)

public DatabaseConnection
openConnection(String url, String username, String driver, String databaseClass, Properties driverProperties, ResourceAccessor resourceAccessor)

public Database
openDatabase(String url, String username, String password, String propertyProviderClass, ResourceAccessor resourceAccessor)

public Database
openDatabase(String url, String username, String password, String driver, String databaseClass, String driverPropertiesFile, String propertyProviderClass, ResourceAccessor resourceAccessor)

public Database
openDatabase(String url, String username, String driver, String databaseClass, Properties driverProperties, ResourceAccessor resourceAccessor)

public void
register(Database database)

public static synchronized void
public static synchronized void
setInstance(DatabaseFactory databaseFactory)

Set singleton instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

implementedDatabasesback to summary
private final Map<String, SortedSet<Database>> implementedDatabases
instanceback to summary
private static DatabaseFactory instance
internalDatabasesback to summary
private final Map<String, SortedSet<Database>> internalDatabases
LOGback to summary
private static final Logger LOG
specifiedDbClassback to summary
private Database specifiedDbClass

Constructor Detail

DatabaseFactoryback to summary
private DatabaseFactory()

Method Detail

buildDriverPropertiesback to summary
private Properties buildDriverProperties(String username, String password, String driverPropertiesFile, String propertyProviderClass)
clearRegistryback to summary
public void clearRegistry()

Removes all registered databases, even built in ones. Useful for forcing a particular database implementation

findCorrectDatabaseImplementationback to summary
public Database findCorrectDatabaseImplementation(DatabaseConnection connection) throws DatabaseException
findDefaultDriverback to summary
public String findDefaultDriver(String url)

Returns the Java class name of the JDBC driver class (e.g. "org.mariadb.jdbc.Driver") for the specified JDBC URL, if any Database class supports that URL.

Parameters
url:String

the JDBC URL to analyse

Returns:String

a Database object supporting the URL. May also return null if the JDBC URL is unknown to all handlers.

findDriverClassback to summary
private String findDriverClass(String url, String driver, DatabaseFactory databaseFactory)
getDatabaseback to summary
public Database getDatabase(String shortName)
getImplementedDatabasesback to summary
public List<Database> getImplementedDatabases()

Returns instances of all implemented database types.

getInstanceback to summary
public static synchronized DatabaseFactory getInstance()
getInternalDatabasesback to summary
public List<Database> getInternalDatabases()

Returns instances of all "internal" database types.

loadDriverback to summary
private Driver loadDriver(String driverClass)
openConnectionback to summary
public DatabaseConnection openConnection(String url, String username, String password, String propertyProvider, ResourceAccessor resourceAccessor) throws DatabaseException
openConnectionback to summary
public DatabaseConnection openConnection(String url, String username, String password, String driver, String databaseClass, String driverPropertiesFile, String propertyProviderClass, ResourceAccessor resourceAccessor) throws DatabaseException
openConnectionback to summary
public DatabaseConnection openConnection(String url, String username, String driver, String databaseClass, Properties driverProperties, ResourceAccessor resourceAccessor) throws DatabaseException
Annotations
@SuppressWarnings:java:S2095
openDatabaseback to summary
public Database openDatabase(String url, String username, String password, String propertyProviderClass, ResourceAccessor resourceAccessor) throws DatabaseException
openDatabaseback to summary
public Database openDatabase(String url, String username, String password, String driver, String databaseClass, String driverPropertiesFile, String propertyProviderClass, ResourceAccessor resourceAccessor) throws DatabaseException
openDatabaseback to summary
public Database openDatabase(String url, String username, String driver, String databaseClass, Properties driverProperties, ResourceAccessor resourceAccessor) throws DatabaseException
registerback to summary
public void register(Database database)
resetback to summary
public static synchronized void reset()
setInstanceback to summary
public static synchronized void setInstance(DatabaseFactory databaseFactory)

Set singleton instance. Primarily used in testing

liquibase.database back to summary

private Class DatabaseFactory.DatabaseComparator

extends Object
implements Comparator<Database>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(Database
the first object to be compared.
o1
,
Database
the second object to be compared.
o2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DatabaseComparatorback to summary
private DatabaseComparator()

Method Detail

compareback to summary
public int compare(Database o1, Database o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
o1:Database

the first object to be compared.

o2:Database

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override