|
Object Translator | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.informix.ormapper.OConnection
External:
This class represents a database connection.
When an Object Translator-generated object is instantiated, an OConnection object
must be assigned to it before it can be used.
The OConnection object can be constructed from a standard JDBC connection
URL or directly from a JDBC Connection
object.
Internally this class wraps around the JDBC connection with some default
behaviors for ease of use.
Field Summary | |
static int |
DETECT_CHANGEDROW
Indicates using changed row indicator for optimistic concurrency change detection. |
static int |
DETECT_NONE
Indicates no change detection for optimistic concurrency. |
static int |
DETECT_QUERIED
Indicates using all queried attributes for optimistic concurrency change detection. |
static int |
DETECT_UPDATED
Indicates using all updated attributes for optimistic concurrency change detection. |
static int |
OPTIMISTIC
Indicates optimistic concurrency locking. |
static int |
PESSIMISTIC
Indicates pessimistic concurrency locking. |
Constructor Summary | |
OConnection(java.sql.Connection conn)
Constructs a connection object by reusing an existing JDBC connection. |
|
OConnection(java.lang.String url,
java.lang.String driverName)
Constructs a connection object, loads the given driver, and establishes a connection to the given database URL. |
|
OConnection(java.lang.String url,
java.lang.String driverName,
java.lang.String userName,
java.lang.String password)
Constructs a connection object from a database URL, a driver name, a user name and a password. |
Method Summary | |
void |
close()
Releases the connection's database and JDBC resources immediately instead of waiting for them to be automatically released. |
void |
commit()
Makes all changes since the previous commit/rollback permanent and releases any database locks currently held by the connection. |
boolean |
getAutoCommit()
Gets the current auto-commit state. |
int |
getDetectType()
Gets the optimistic concurrency detect type for the connection. |
java.sql.Connection |
getJdbcConnection()
Returns the JDBC connection object. |
java.util.Locale |
getLocale()
Gets the current locale for the Object Translator runtime. |
int |
getLockType()
Gets the concurrency locking type of this connection. |
java.util.Map |
getTypeMap()
Gets the custom type map for this connection. |
boolean |
isClosed()
Tests to see if the connection is closed. |
boolean |
isReadOnly()
Tests to see if the connection is in read-only mode. |
void |
rollback()
Drops all changes made since the previous commit/rollback and releases any database locks currently held by the connection. |
void |
setAutoCommit(boolean autoCommit)
Sets this connection's auto-commit mode. |
void |
setDetectType(int type)
Sets the optimistic concurrency detect type for the connection. |
void |
setLocale(java.util.Locale locale)
Sets the current locale for the Object Translator runtime. |
void |
setLockType(int _lockType)
Sets the concurrency locking for this connection to OPTIMISTIC , or PESSIMISTIC . |
void |
setReadOnly(boolean readOnly)
Sets this connection to read-only mode as a hint to enable database optimizations. Note: This method cannot be called while in the middle of a transaction. |
void |
setTypeMap(java.util.Map map)
Sets a custom type map for this connection. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int OPTIMISTIC
java.sql.Connection.TRANSACTION_READ_COMMITTED
.
This is the default.public static final int PESSIMISTIC
java.sql.Connection.TRANSACTION_SERIALIZABLE
,
or TRANSACTION_REPEATABLE_READ
.public static final int DETECT_NONE
public static final int DETECT_CHANGEDROW
public static final int DETECT_UPDATED
public static final int DETECT_QUERIED
Constructor Detail |
public OConnection(java.sql.Connection conn) throws DatabaseException
conn
- an existing JDBC connection.conn
is null
or closed.public OConnection(java.lang.String url, java.lang.String driverName) throws DatabaseException, NoDriverException
url
- a database url of the form
jdbc:subprotocol:subname
.driverName
- the class name of the database driver to be loaded.
If null
, the default is
com.informix.jdbc.IfxDriver
.public OConnection(java.lang.String url, java.lang.String driverName, java.lang.String userName, java.lang.String password) throws DatabaseException, NoDriverException
url
- a database url of the form
jdbc:subprotocol:subname
.driverName
- the class name of the database driver to be loaded.
If null
, the default is
com.informix.jdbc.IfxDriver
.userName
- the database user on whose behalf the connection
is being made; can be null
.password
- the password associated with userName
;
can be null
.Method Detail |
public java.sql.Connection getJdbcConnection()
public void setReadOnly(boolean readOnly) throws DatabaseException
readOnly
- true
enables read-only mode;
false
disables read-only mode.public boolean isReadOnly() throws DatabaseException
true
if connection is read-only.public java.util.Locale getLocale()
public void setLocale(java.util.Locale locale)
locale
- the new localepublic int getLockType()
OPTIMISTIC
, or PESSIMISTIC
.public void setLockType(int _lockType) throws DatabaseException
OPTIMISTIC
, or PESSIMISTIC
.
If PESSIMISTIC
, transaction isolation level of the
connection will be set to
java.sql.Connection.TRANSACTION_SERIALIZABLE
,
or TRANSACTION_REPEATABLE_READ
, depending on
the highest level of support available from the database server.
_lockType
- OPTIMISTIC
, or PESSIMISTIC
.public int getDetectType()
DETECT_NONE
, DETECT_CHANGEDROW
,
DETECT_UPDATED
, or DETECT_QUERIED
public void setDetectType(int type)
type
- DETECT_NONE
, DETECT_CHANGEDROW
,
DETECT_UPDATED
, or DETECT_QUERIED
public void setAutoCommit(boolean autoCommit) throws DatabaseException
commit
or the method rollback
.
By default, new connections are in auto-commit
mode.
The commit occurs when the statement completes or the next
execute occurs, whichever comes first. In the case of
statements returning a ResultSet, the statement completes when
the last row of the ResultSet has been retrieved or the
ResultSet has been closed.autoCommit
- true enables auto-commit; false disables
auto-commit.public boolean getAutoCommit() throws DatabaseException
setAutoCommit(boolean)
public void commit() throws DatabaseException
setAutoCommit(boolean)
public void rollback() throws DatabaseException
setAutoCommit(boolean)
public void close() throws DatabaseException
public boolean isClosed() throws DatabaseException
true
if the connection is closed;
false
if it is still open.public void setTypeMap(java.util.Map map) throws DatabaseException
map
- the custom type map.public java.util.Map getTypeMap() throws DatabaseException
|
Object Translator | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |