|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eoaccess.EOAdaptor com.webobjects.jdbcadaptor.JDBCAdaptor
public class JDBCAdaptor
JDBCAdaptor is a concrete subclass of EOAdaptor that use JDBC for connecting to a database. It can be customized for a particular database and JDBC driver by using a JDBCPlugIn. Application code rarely needs to interact directly with an adaptor and should not normally use adaptor-specific API. All the useful API resides in EOAdaptor and the other generic EOAccess framework classes.
EOAdaptor
,
JDBCPlugIn
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.webobjects.eoaccess.EOAdaptor |
---|
EOAdaptor.Delegate |
Field Summary | |
---|---|
static String |
DataSourceJndiNameKey
Key for JNDI datasource name |
static String |
DriverKey
Key labeling the JDBC driver class name in the connection dictionary. |
static String |
JDBCInfoKey
Connection dictionary key labeling database-specific information contained in an NSDictionary, commonly referred to as "JDBC info". |
static String |
PasswordKey
Key labeling the password in the connection dictionary. |
static String |
PlugInKey
Key labeling the plugin class name in the connection dictionary. |
static String |
TypeInfoKey
Key labeling the NSDictionary of external type information in the JDBC info dictionary. |
static String |
URLKey
Key labeling the JDBC URL String in the connection dictionary. |
static String |
UsernameKey
Key labeling the user name in the connection dictionary. |
Constructor Summary | |
---|---|
JDBCAdaptor(String name)
Create a JDBCAdaptor. |
Method Summary | |
---|---|
void |
assertConnectionDictionaryIsValid()
Checks that the connectionary dictionary is valid by attempting to make a connection. |
void |
assignExternalTypeForAttribute(EOAttribute attribute)
Assigns an appropriate external type to the attribute . |
boolean |
canServiceModel(EOModel model)
Returns true if the adaptor is compatible with the
model ; false otherwise. |
protected String |
connectionDictionaryURL()
Returns the JDBC URL from the adaptor's connection dictionary. |
Properties |
connectionProperties()
Returns a Properties object specifying connection information. |
String |
connectionURL()
Returns the JDBC URL that should be used for connecting to the database as specified by the plugin. |
EOAdaptorContext |
createAdaptorContext()
Returns a new JDBCContext for this adaptor. |
EOAttribute |
createAttribute(String name,
String columnName,
int columnType,
String externalType,
int precision,
int scale,
int isNullable)
Returns a new EOAttribute based on the arguments. |
Class |
defaultExpressionClass()
Returns the expression class to use for this adaptor. |
String |
driverName()
Returns the JDBC driver's name. |
EOSQLExpressionFactory |
expressionFactory()
Returns the expression factory to use for this adaptor. |
String |
externalTypeForJDBCType(int type)
Returns the name of an external type that matches the given JDBC type type . |
NSArray |
externalTypesWithModel(EOModel model)
Returns an NSArray of external type names for the model . |
Object |
fetchedValueForValue(Object value,
EOAttribute attribute)
Calls super with the result of the plugIn's
plugInValueForValue . |
protected static NSDictionary |
getJDBCInfoWithConnectionDictionary(NSDictionary connectionDictionary)
|
void |
handleDroppedConnection()
Handles cleaning up when a connection is dropped. |
boolean |
isDroppedConnectionException(Exception exception)
Returns true if exception is a
JDBCAdaptorException and it is considered a "dropped" connection;
otherwise false . |
boolean |
isValidQualifierType(String typeName,
EOModel model)
An abstract method that should be implemented by subclasses to return true if an attribute of type typeName can be used in a qualifier (an SQL WHERE clause) sent to the database server, false otherwise. |
protected NSDictionary |
jdbcInfo()
Returns an NSDictionary of database-specific information. |
String |
password()
Returns the password from the adaptor's connection dictionary. |
JDBCPlugIn |
plugIn()
Returns the JDBCPlugIn to use with this adaptor's connection dictionary. |
String |
plugInName()
Returns the adaptor's plug-in name. |
EOSchemaSynchronizationFactory |
schemaSynchronizationFactory()
An abstract method that supports changes made to EOSQLExpression and related classes and interfaces. |
void |
setConnectionDictionary(NSDictionary dictionary)
Sets the adaptor's connection dictionary to dictionary , which must only contain String, NSData, NSDictionary, and NSArray objects. |
static String |
stringRepresentationForJDBCType(int columnType)
|
EOSchemaGeneration |
synchronizationFactory()
Deprecated. |
protected NSDictionary |
typeInfo()
Returns an NSDictionary of external type information. |
protected static NSDictionary |
typeInfoForModel(EOModel model)
|
String |
username()
Returns the user name from the adaptor's connection dictionary. |
protected int |
varcharMaxLength()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String JDBCInfoKey
JDBCAdaptor.jdbcInfo()
,
Constant Field Valuespublic static final String DataSourceJndiNameKey
public static final String TypeInfoKey
public static final String UsernameKey
public static final String PasswordKey
public static final String DriverKey
public static final String PlugInKey
public static final String URLKey
Constructor Detail |
---|
public JDBCAdaptor(String name)
EOAdaptor.adaptorWithModel(com.webobjects.eoaccess.EOModel)
,
EOAdaptor.adaptorWithName(java.lang.String)
Method Detail |
---|
public void setConnectionDictionary(NSDictionary dictionary) throws IllegalArgumentException
EOAdaptor
dictionary
, which must only contain String, NSData, NSDictionary, and NSArray objects. Connection information can not be changed while the adaptor is connected. Throws an exception if there are any open channels when this method is
invoked.
Subclasses of EOAdaptor don't need to override this method. A subclass that does override this method must incorporate the superclass's version by calling super
.
setConnectionDictionary
in class EOAdaptor
dictionary
- The adaptor's connection dictionary.
IllegalArgumentException
- if there are any open channels when this method is called.EOAdaptor.connectionDictionary()
,
EOAdaptor.hasOpenChannels()
,
EOAdaptor.assertConnectionDictionaryIsValid()
protected NSDictionary jdbcInfo()
JDBCPlugIn.jdbcInfo()
,
JDBCAdaptor.typeInfo()
protected NSDictionary typeInfo()
JDBCAdaptor.jdbcInfo()
public Properties connectionProperties()
JDBCPlugIn.connectionPropertiesForConnectionDictionary(com.webobjects.foundation.NSDictionary)
public boolean canServiceModel(EOModel model)
true
if the adaptor is compatible with the
model
; false
otherwise. The decision is
made by matching the connection dictionary of the adaptor against that of
the model
considering the following keys:
URLKey
, UsernameKey
,
PasswordKey
, DriverKey
, and
PlugInKey
.
canServiceModel
in class EOAdaptor
model
- A model.
true
if this adaptor instance can service database access requests for this model.JDBCAdaptor.URLKey
,
JDBCAdaptor.UsernameKey
,
JDBCAdaptor.PasswordKey
,
JDBCAdaptor.DriverKey
,
JDBCAdaptor.PlugInKey
protected int varcharMaxLength()
public void assertConnectionDictionaryIsValid()
assertConnectionDictionaryIsValid
in class EOAdaptor
JDBCAdaptorException
public EOAdaptorContext createAdaptorContext()
createAdaptorContext
in class EOAdaptor
EOAdaptor.contexts()
public void handleDroppedConnection()
handleDroppedConnection
in class EOAdaptor
EOAdaptor.Delegate.reconnectionDictionaryForAdaptor(EOAdaptor adaptor)
,
EOAdaptorContext.handleDroppedConnection()
public JDBCPlugIn plugIn()
EOAdaptor.connectionDictionary()
,
JDBCAdaptor.PlugInKey
public String plugInName()
plugInName
in class EOAdaptor
public Class defaultExpressionClass()
defaultExpressionClass
in class EOAdaptor
JDBCPlugIn.defaultExpressionClass()
,
JDBCExpression
public EOSQLExpressionFactory expressionFactory()
expressionFactory
in class EOAdaptor
JDBCPlugIn.expressionFactory()
,
JDBCExpressionFactory
public EOSchemaSynchronizationFactory schemaSynchronizationFactory()
EOAdaptor
schemaSynchronizationFactory
in class EOAdaptor
EOSQLExpression
@Deprecated public EOSchemaGeneration synchronizationFactory()
EOAdaptor
synchronizationFactory
in class EOAdaptor
EOSQLExpression
public Object fetchedValueForValue(Object value, EOAttribute attribute)
super
with the result of the plugIn's
plugInValueForValue
. This allows a PlugIn to influence
the value. The basic behavior is the same as
EOAdaptor.fetchedValueForValue
.
fetchedValueForValue
in class EOAdaptor
value
- The original value.attribute
- The attribute corresponding to the database column in which
value
would be stored.
value
, or the new value.JDBCPlugIn.plugInValueForValue(java.lang.Object, com.webobjects.eoaccess.EOAttribute)
public NSArray externalTypesWithModel(EOModel model)
model
.
This information is often cached in the connection dictionary of the
model
, but the adaptor can also fetch it at runtime.
externalTypesWithModel
in class EOAdaptor
model
- An optional argument that can be used to supplement the adaptor's set of database types with additional, user-defined database types.
public String externalTypeForJDBCType(int type)
type
.
public boolean isValidQualifierType(String typeName, EOModel model)
EOAdaptor
true
if an attribute of type typeName
can be used in a qualifier (an SQL WHERE clause) sent to the database server, false
otherwise. typeName
is the name of a type
as required by the database server. model
is an optional argument that can be used to supplement the adaptor's set of type mappings with additional mappings for user-defined database types.
isValidQualifierType
in class EOAdaptor
typeName
- The name of a type as determined by the database server.model
- A model.
true
if an attribute of type typeName
can be used in a qualifier.protected String connectionDictionaryURL()
public String connectionURL()
JDBCPlugIn.connectionURL()
public String username()
public String password()
public String driverName()
JDBCPlugIn.defaultDriverName()
public EOAttribute createAttribute(String name, String columnName, int columnType, String externalType, int precision, int scale, int isNullable)
name
- the name of the attributecolumnType
- the JDBC type for the attributeexternalType
- the external type for the attributeprecision
- the precision (or width) of the attributescale
- the scale of the attributeisNullable
- boolean indicating if the attribute allows NULL
protected static NSDictionary typeInfoForModel(EOModel model)
protected static NSDictionary getJDBCInfoWithConnectionDictionary(NSDictionary connectionDictionary) throws JDBCAdaptorException
JDBCAdaptorException
public static String stringRepresentationForJDBCType(int columnType)
public boolean isDroppedConnectionException(Exception exception)
true
if exception
is a
JDBCAdaptorException and it is considered a "dropped" connection;
otherwise false
. The adaptor will try to reconnect
automatically from a dropped connection. The decision is based on the
SQLState
of the underlying SQLException that is wrapped by
the JDBCAdaptorException. For any other type of Exception, this method
returns false
.
This method defer the decision to the plug-in so that each database vendor can customize teh error detection.
isDroppedConnectionException
in class EOAdaptor
exception
- An exception object.
true
if exception
is a "dropped"
connection; otherwise false
EOAdaptor.handleDroppedConnection()
,
EOAdaptor.Delegate.reconnectionDictionaryForAdaptor( EOAdaptor adaptor)
public void assignExternalTypeForAttribute(EOAttribute attribute)
attribute
.
The attribute should already have a value class, scale and precision.
This method is invoked when reverse engineering or switching adaptors.
assignExternalTypeForAttribute
in class EOAdaptor
attribute
- The attribute for which to set a corresponding external type.EOAdaptor.assignExternalInfoForEntireModel(EOModel model)
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |