public abstract class AbstractConnectionCreator extends java.lang.Object implements ConnectionCreator
Constructor and Description |
---|
AbstractConnectionCreator() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
allowNullPassword()
Returns false by default if
password is an allowed property. |
protected java.util.ResourceBundle |
getBundle()
Deprecated.
|
java.sql.Connection |
getConnection(java.util.Properties props)
Default implementation uses the standard properties for username and password, and the URL and driver class name to create a connection.
|
java.lang.String |
getConnectionURL(java.util.Properties props)
The default implementation on this abstract class return the DatabaseProvider.DRIVER_CLASS_REFTYPE property.
|
java.lang.String |
getDriverClassName(java.util.Properties props)
The default implementation on this class returns the DatabaseProvider.CUSTOM_URL_CLASS_REFTYPE property.
|
protected java.lang.String |
getInvalidURLMessage()
Gets the translated message to use for the SQLException thrown when the DriverManager returns no connection, signifying that the URL was not valid.
|
protected java.lang.String |
getPropertyOrThrow(java.util.Properties props, java.lang.String name)
Utility method to retrieve a property from the given Properties and throw an exception is the property is missing or empty.
|
protected boolean |
hasLength(java.lang.String s)
Utility method to check a string isn't null or empty.
|
java.util.Collection<java.lang.String> |
listAllowedProperties()
Gets a list of the properties that are relevant to this creator.
|
protected void |
setCustomProperties(java.util.Properties connProps, java.util.Properties jdbcProps)
Override to include connection type specific properties in the jdbc properties set that the driver will be created with.
|
boolean |
shouldEncrypt(java.lang.String propName)
By default only the password (
DatabaseProvider.PASSWORD_CLASS_REFTYPE ) is encrypted. |
boolean |
shouldPromptForPassword(java.util.Properties props)
By default the password is prompted for if
password is an allowed property, it is not set and a null password is not alloewd, and save password is set to false. |
@Deprecated protected java.util.ResourceBundle getBundle()
public boolean shouldEncrypt(java.lang.String propName)
DatabaseProvider.PASSWORD_CLASS_REFTYPE
) is encrypted.shouldEncrypt
in interface ConnectionCreator
public boolean shouldPromptForPassword(java.util.Properties props)
password
is an allowed property, it is not set and a null password is not alloewd, and save password
is set to false.shouldPromptForPassword
in interface ConnectionCreator
props
- the connection details that might need a password prompted forlistAllowedProperties()
, allowNullPassword()
protected void setCustomProperties(java.util.Properties connProps, java.util.Properties jdbcProps)
Username, password and role are done by default by this abstract creator.
connProps
- the connection properties defined in the connection definition.jdbcProps
- the properties that will be used to create the JDBC connectionpublic java.sql.Connection getConnection(java.util.Properties props) throws java.sql.SQLException
When loading the JDBC driver class a ClassLoader for the class is searched for in the following order (if any ClassLoader loads the Class it is used, otherwise the next in the list is tested):
Thread.currentThread().getContextClassLoader()
ClassLoader.getSystemClassLoader()
getConnection
in interface ConnectionCreator
props
- the Properties containing the connection datajava.sql.SQLException
- if the connection cannot be created because the data is wrong or the database is down.getConnectionURL(Properties)
, getDriverClassName(Properties)
protected java.lang.String getInvalidURLMessage()
protected boolean allowNullPassword()
password
is an allowed property.listAllowedProperties()
protected boolean hasLength(java.lang.String s)
protected java.lang.String getPropertyOrThrow(java.util.Properties props, java.lang.String name) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getConnectionURL(java.util.Properties props) throws java.sql.SQLException
getConnectionURL
in interface ConnectionCreator
java.sql.SQLException
public java.lang.String getDriverClassName(java.util.Properties props) throws java.sql.SQLException
getDriverClassName
in interface ConnectionCreator
java.sql.SQLException
public java.util.Collection<java.lang.String> listAllowedProperties()
ConnectionCreator
listAllowedProperties
in interface ConnectionCreator