Top Description Fields Constructors Methods
org.eclipse.persistence.sessions

public Class DefaultConnector

extends Object
implements Connector
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.sessions.Connector, java.lang.Cloneable, java.io.Serializable
Known Direct Subclasses
org.eclipse.persistence.sessions.DirectConnector
Imports
java.util.*, java.security.AccessController, .PrivilegedActionException, java.sql.*, java.io.*, org.eclipse.persistence.internal.helper.*, org.eclipse.persistence.exceptions.*, org.eclipse.persistence.internal.localization.*, org.eclipse.persistence.internal.security.PrivilegedAccessHelper, .PrivilegedClassForName, .PrivilegedNewInstanceFromClass, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.logging.SessionLog

Purpose:Use this Connector to build a java.sql.Connection in the "standard" fashion, via the DriverManager.

Author
Big Country
Since
TOPLink/Java 2.1

Field Summary

Modifier and TypeField and Description
private boolean
connectDirectly

Save whether we have switched to direct connect (sql.Driver.connect()) mode

protected String
protected Driver
driver

cache up the instantiated Driver to speed up reconnects

protected Class<?>
driverClass

cache up the driver class to speed up reconnects

protected String
protected String

Constructor Summary

AccessConstructor and Description
public
DefaultConnector()

PUBLIC: Construct a Connector with default settings The database URL will still need to be set.

public
DefaultConnector(String driverClassName, String driverURLHeader, String databaseURL)

PUBLIC: Construct a Connector with the specified settings.

Method Summary

Modifier and TypeMethod and Description
public void
clearDriverClassAndDriver()

INTERNAL: Discard the cached driver class and driver.

public Object
clone()

Overrides java.lang.Object.clone.

Implements org.eclipse.persistence.sessions.Connector.clone.

INTERNAL: Clone the connector.
public Connection

Returns:

java.sql.Connection
connect
(Properties properties, Session session)

Implements org.eclipse.persistence.sessions.Connector.connect.

INTERNAL: Connect with the specified properties and session.
protected Connection

Returns:

java.sql.Connection
directConnect
(Properties properties)

INTERNAL: Connect directly - without using DriverManager.

public String

Returns:

java.lang.String
getConnectionDetails
()

Implements org.eclipse.persistence.sessions.Connector.getConnectionDetails.

PUBLIC: Provide the details of my connection information.
public String
getConnectionString()

PUBLIC: Return the JDBC connection string.

public String
getDatabaseURL()

PUBLIC: The database URL is the JDBC URL for the database server.

public String
getDriverClassName()

PUBLIC: The driver class is the name of the Java class for the JDBC driver being used (e.g. "sun.jdbc.odbc.JdbcOdbcDriver").

public String
getDriverURLHeader()

PUBLIC: The driver URL header is the string predetermined by the JDBC driver to be part of the URL connection string, (e.g. "jdbc:odbc:").

protected void
initialize(String driverClassName, String driverURLHeader, String databaseURL)

INTERNAL: Initialize the connector with the specified settings.

protected void
instantiateDriver()

INTERNAL: Instantiate the Driver.

protected void
loadDriverClass(Session session)

INTERNAL: Ensure that the driver has been loaded and registered with the DriverManager.

public void
setDatabaseURL(String databaseURL)

PUBLIC: The database URL is the JDBC URL for the database server.

public void
setDriverClassName(String driverClassName)

PUBLIC: The driver class is the name of the Java class for the JDBC driver being used (e.g. "sun.jdbc.odbc.JdbcOdbcDriver").

public void
setDriverURLHeader(String driverURLHeader)

PUBLIC: The driver URL header is the string predetermined by the JDBC driver to be part of the URL connection string, (e.g. "jdbc:odbc:").

public boolean

Returns:

boolean
shouldUseDriverManager
(Properties properties, Session session)

INTERNAL: Indicates whether DriverManager should be used.

public String
toString()

Overrides java.lang.Object.toString.

PUBLIC: Print connection string.
public void
toString(PrintWriter writer)

Implements org.eclipse.persistence.sessions.Connector.toString.

INTERNAL: Print something useful on the log.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

connectDirectlyback to summary
private boolean connectDirectly

Save whether we have switched to direct connect (sql.Driver.connect()) mode

databaseURLback to summary
protected String databaseURL
driverback to summary
protected Driver driver

cache up the instantiated Driver to speed up reconnects

driverClassback to summary
protected Class<?> driverClass

cache up the driver class to speed up reconnects

driverClassNameback to summary
protected String driverClassName
driverURLHeaderback to summary
protected String driverURLHeader

Constructor Detail

DefaultConnectorback to summary
public DefaultConnector()

PUBLIC: Construct a Connector with default settings The database URL will still need to be set.

DefaultConnectorback to summary
public DefaultConnector(String driverClassName, String driverURLHeader, String databaseURL)

PUBLIC: Construct a Connector with the specified settings.

Method Detail

clearDriverClassAndDriverback to summary
public void clearDriverClassAndDriver()

INTERNAL: Discard the cached driver class and driver.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Implements org.eclipse.persistence.sessions.Connector.clone.

INTERNAL: Clone the connector.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
connectback to summary
public Connection connect(Properties properties, Session session) throws DatabaseException

Implements org.eclipse.persistence.sessions.Connector.connect.

INTERNAL: Connect with the specified properties and session. Return the Connection.

Returns:Connection

java.sql.Connection

Annotations
@Override
directConnectback to summary
protected Connection directConnect(Properties properties) throws DatabaseException

INTERNAL: Connect directly - without using DriverManager. Return the Connection.

Returns:Connection

java.sql.Connection

getConnectionDetailsback to summary
public String getConnectionDetails()

Implements org.eclipse.persistence.sessions.Connector.getConnectionDetails.

PUBLIC: Provide the details of my connection information. This is primarily for JMX runtime services.

Returns:String

java.lang.String

Annotations
@Override
getConnectionStringback to summary
public String getConnectionString()

PUBLIC: Return the JDBC connection string. This is a combination of the driver-specific URL header and the database URL.

getDatabaseURLback to summary
public String getDatabaseURL()

PUBLIC: The database URL is the JDBC URL for the database server. The driver header is not be included in this URL (e.g. "dbase files"; not "jdbc:odbc:dbase files").

getDriverClassNameback to summary
public String getDriverClassName()

PUBLIC: The driver class is the name of the Java class for the JDBC driver being used (e.g. "sun.jdbc.odbc.JdbcOdbcDriver").

getDriverURLHeaderback to summary
public String getDriverURLHeader()

PUBLIC: The driver URL header is the string predetermined by the JDBC driver to be part of the URL connection string, (e.g. "jdbc:odbc:"). This is required to connect to the database.

initializeback to summary
protected void initialize(String driverClassName, String driverURLHeader, String databaseURL)

INTERNAL: Initialize the connector with the specified settings.

instantiateDriverback to summary
protected void instantiateDriver() throws DatabaseException

INTERNAL: Instantiate the Driver.

loadDriverClassback to summary
protected void loadDriverClass(Session session) throws DatabaseException

INTERNAL: Ensure that the driver has been loaded and registered with the DriverManager. Just loading the class should cause the static initialization code to do the necessary registration. Return the loaded driver Class.

setDatabaseURLback to summary
public void setDatabaseURL(String databaseURL)

PUBLIC: The database URL is the JDBC URL for the database server. The driver header is not be included in this URL (e.g. "dbase files"; not "jdbc:odbc:dbase files").

setDriverClassNameback to summary
public void setDriverClassName(String driverClassName)

PUBLIC: The driver class is the name of the Java class for the JDBC driver being used (e.g. "sun.jdbc.odbc.JdbcOdbcDriver").

setDriverURLHeaderback to summary
public void setDriverURLHeader(String driverURLHeader)

PUBLIC: The driver URL header is the string predetermined by the JDBC driver to be part of the URL connection string, (e.g. "jdbc:odbc:"). This is required to connect to the database.

shouldUseDriverManagerback to summary
public boolean shouldUseDriverManager(Properties properties, Session session)

INTERNAL: Indicates whether DriverManager should be used.

Returns:boolean

boolean

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

PUBLIC: Print connection string.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
toStringback to summary
public void toString(PrintWriter writer)

Implements org.eclipse.persistence.sessions.Connector.toString.

INTERNAL: Print something useful on the log.

Annotations
@Override