public class DatabaseProvider
extends java.lang.Object
implements javax.naming.Referenceable, javax.sql.DataSource
This class is also a DataSource and is therefore capable of creating a
java.sql.Connection
to the database as well.
If the connection details are required to separately connect to the
database (e.g. via java.sql.DriverManager
), then there are two
methods that provide the information required:
getConnectionURL()
to get the jdbc urlgetJDBCProperties()
to get the info properties that
accompany the URL (includes user/password when required).getDriverClassName()
might also be
required.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALL_SCHEMAS_REFTYPE
Deprecated.
with no replacement.
|
static java.lang.String |
CUSTOM_URL_CLASS_REFTYPE
The URL for the database connection.
|
static java.lang.String |
DEPLOY_PASSWORD_CLASS_REFTYPE
Deprecated.
with no replacement.
|
static java.lang.String |
DRIVER_CLASS_REFTYPE
The JDBC driver class.
|
static java.lang.String |
DSN_CLASS_REFTYPE
The source name of the database.
|
static java.lang.String |
HOSTNAME_CLASS_REFTYPE
The hostname of the database machine.
|
static java.lang.String |
INSTANCE_CLASS_REFTYPE
Deprecated.
- moved to
SQLServerConnectionCreator.INSTANCE_CLASS_REFTYPE . Database
specific keys belong on the appropriate ConnectionCreator subclasses. |
static java.lang.String |
PARAMETERS_CLASS_REFTYPE
Extra parameters for the JDBC driver.
|
static java.lang.String |
PASSWORD_CLASS_REFTYPE
The database password.
|
static java.lang.String |
PORT_CLASS_REFTYPE
The network port the database is running on.
|
static java.lang.String |
ROLE_CLASS_REFTYPE
The database roles to associated with the connection session.
|
static java.lang.String |
SAVE_PASSWORD_CLASS_REFTYPE
Whether to persist the password with the connection details.
|
static java.lang.String |
SERVICENAME_CLASS_REFTYPE
The service name of the database (Oracle).
|
static java.lang.String |
SID_CLASS_REFTYPE
The SID name of the database (Oracle).
|
static java.lang.String |
SUBTYPE_CLASS_REFTYPE
The subtype of the database connection.
|
static java.lang.String |
USERNAME_CLASS_REFTYPE
The database username.
|
Constructor and Description |
---|
DatabaseProvider()
Creates an empty DatabaseProvider.
|
DatabaseProvider(java.util.Properties props)
Creates a new DatabaseProvider using the given properties.
|
DatabaseProvider(java.lang.String name,
java.util.Properties props)
Creates a new DatabaseProvider using the given properties and with the
given name.
|
Modifier and Type | Method and Description |
---|---|
void |
disconnect()
Notifies this provider that the connection(s) associated with it have been
closed.
|
boolean |
equals(java.lang.Object obj) |
javax.naming.directory.Attributes |
getAttributes() |
java.sql.Connection |
getConnection() |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password) |
java.lang.String |
getConnectionURL()
Returns the URL for the connection.
|
static ConnectionCreator |
getCreator(DatabaseProvider dp)
Gets a ConnectionCreator for the given DatabaseProvider, or throws
a SQLException if the given provider doesn't have a subtype for which
a ConnectionCreator is registered.
|
java.lang.String |
getDriverClassName()
Gets the driver class for the connection.
|
java.util.Properties |
getJDBCProperties()
Gets the full set of properties needed to create the connection.
|
int |
getLoginTimeout() |
java.io.PrintWriter |
getLogWriter() |
java.util.logging.Logger |
getParentLogger() |
java.util.Properties |
getProperties()
Returns a copy of the underlying properties for this provider.
|
java.lang.String |
getProperty(java.lang.String name)
Returns the value for the specified property on this provider.
|
javax.naming.Reference |
getReference() |
int |
hashCode() |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
static void |
registerConnectionCreator(java.lang.String subtype,
ConnectionCreator creator)
Registers a ConnectionCreator implementation for a new connection subtype.
|
static void |
setClassLoaderFactory(DatabaseProviderClassLoaderFactory factory) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
void |
setProperty(java.lang.String name,
java.lang.String value)
Sets the given property on this provider.
|
void |
setReferenceWorker(oracle.jdevimpl.db.adapter.ReferenceWorker worker)
Internal use only - sets the reference worker that this provider should
use when creating a Referenceable.
|
boolean |
shouldPromptForCredentials()
Tests whether the Properties of this DatabaseProvider are sufficient to
create a Connection, or whether the user should be prompted for the
username and password.
|
<T> T |
unwrap(java.lang.Class<T> iface) |
public static final java.lang.String SUBTYPE_CLASS_REFTYPE
public static final java.lang.String CUSTOM_URL_CLASS_REFTYPE
public static final java.lang.String DRIVER_CLASS_REFTYPE
public static final java.lang.String USERNAME_CLASS_REFTYPE
public static final java.lang.String PASSWORD_CLASS_REFTYPE
public static final java.lang.String ROLE_CLASS_REFTYPE
public static final java.lang.String HOSTNAME_CLASS_REFTYPE
public static final java.lang.String PORT_CLASS_REFTYPE
public static final java.lang.String SID_CLASS_REFTYPE
service name
.public static final java.lang.String DSN_CLASS_REFTYPE
@Deprecated public static final java.lang.String INSTANCE_CLASS_REFTYPE
SQLServerConnectionCreator.INSTANCE_CLASS_REFTYPE
. Database
specific keys belong on the appropriate ConnectionCreator subclasses.public static final java.lang.String PARAMETERS_CLASS_REFTYPE
JDBCParametersParser
,
Constant Field Valuespublic static final java.lang.String SERVICENAME_CLASS_REFTYPE
SID
.public static final java.lang.String SAVE_PASSWORD_CLASS_REFTYPE
@Deprecated public static final java.lang.String DEPLOY_PASSWORD_CLASS_REFTYPE
@Deprecated public static final java.lang.String ALL_SCHEMAS_REFTYPE
public DatabaseProvider()
public DatabaseProvider(java.util.Properties props)
public DatabaseProvider(java.lang.String name, java.util.Properties props)
public void setReferenceWorker(oracle.jdevimpl.db.adapter.ReferenceWorker worker)
public javax.naming.Reference getReference()
getReference
in interface javax.naming.Referenceable
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
getLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
setLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public int getLoginTimeout() throws java.sql.SQLException
getLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLoginTimeout(int seconds) throws java.sql.SQLException
setLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException
public java.util.logging.Logger getParentLogger()
getParentLogger
in interface javax.sql.CommonDataSource
public java.lang.String getConnectionURL() throws java.sql.SQLException
java.sql.SQLException
- if a valid connection URL cannot be created from
the properties in this referenceable.public java.util.Properties getJDBCProperties() throws java.sql.SQLException
java.sql.SQLException
- if a valid set of properties cannot be created
the properties in this referenceable.public java.lang.String getDriverClassName() throws java.sql.SQLException
java.sql.SQLException
- if the driver class name cannot be determined from
the properties in this referenceable.public boolean shouldPromptForCredentials()
This will return false if the SUBTYPE_CLASS_REFTYPE
property
is missing or invalid.
public java.lang.String getProperty(java.lang.String name)
public java.util.Properties getProperties()
public void setProperty(java.lang.String name, java.lang.String value)
public void disconnect()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public javax.naming.directory.Attributes getAttributes()
public static void setClassLoaderFactory(DatabaseProviderClassLoaderFactory factory)
public static ConnectionCreator getCreator(DatabaseProvider dp) throws java.sql.SQLException
dp
- the provider instance to lookup a creator forjava.sql.SQLException
- if the provider's subtype doesn't have a
registered created.public static void registerConnectionCreator(java.lang.String subtype, ConnectionCreator creator)
subtype
- the subtype for the connectioncreator
- the creator responsible for creating connections of the
given subtype.