|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjects.AbstractContainer
de.mguennewig.pobjects.jdbc.JdbcContainer
public abstract class JdbcContainer
Common base class for standard JDBC based database connections.
This container caches the PObject instances for faster access.
| Field Summary |
|---|
| Fields inherited from interface de.mguennewig.pobjects.Container |
|---|
SUPPORTS_BOOLEAN, SUPPORTS_INHERITS, SUPPORTS_JOIN, SUPPORTS_LIMIT_OFFSET, SUPPORTS_ORACLE_JOIN, SUPPORTS_SQL99_JOIN, USE_ARRAY_FOR_LOB, USE_STREAM_TO_INSERT_LOB |
| Constructor Summary | |
|---|---|
JdbcContainer(java.sql.Connection conn,
PObjDictionary dict,
java.lang.String schema)
Creates a container with a specified connection to a DBMS. |
|
JdbcContainer(PObjDictionary dict,
java.lang.String schema)
Creates a container without a connection to any DBMS. |
|
JdbcContainer(java.lang.String hostname,
java.lang.Integer port,
java.lang.String database,
java.lang.String username,
java.lang.String password,
PObjDictionary dict,
java.lang.String schema)
Creates a container that opens a connection to the specified database. |
|
| Method Summary | |
|---|---|
void |
addArguments(java.sql.PreparedStatement statm,
SqlStatement sql,
java.lang.Object[] arguments)
Adds the arguments for the given SQL statement to the prepared statement. |
void |
addParameter(java.sql.PreparedStatement statm,
int pos,
Type t,
java.lang.Object value)
|
void |
beginTransaction()
Starts a new transaction. |
void |
close()
|
void |
commitTransaction()
Commits all statements since the last Container.beginTransaction(). |
int |
deleteAll(ClassDecl te)
Deletes all entries within the specified table. |
int |
deleteAll(ClassDecl cl,
Column fk,
java.lang.Object value)
Deletes all entries within the specified table whose foreign key fk equals the given value. |
void |
deleteObject(PObject obj)
Deletes the given persistent object from the database. |
boolean |
deleteRecord(Record obj)
|
java.sql.Connection |
getConnection()
Returns the connection to the DBMS if any exists. |
java.util.Properties |
getConnectProperties()
|
abstract java.lang.String |
getConnectURL(java.lang.String hostname,
java.lang.Integer port,
java.lang.String database)
|
PObject |
getObject(ClassDecl cdecl,
java.lang.String id)
Returns a PObject instance for the given
table expression without reading any data from the DB. |
boolean |
insertRecord(Record obj)
|
java.lang.String |
mapClassDeclToPClassId(ClassDecl cd)
Maps the given ClassDecl to the pclass id used in the
DBMS. |
ClassDecl |
mapPClassIdToClassDecl(java.lang.String id)
Maps the given pclass id as used by the DBMS to the correct ClassDecl. |
EvalContext |
newEvalContext(int numColumns)
|
Query |
newQuery()
Creates a new empty query. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int scrollType,
int concurrType)
|
void |
reset()
Resets the container. |
void |
retrieveData(PObject obj)
Retrieves the data for the given persistent object from the database. |
void |
rollbackTransaction()
Rolls back all statements since the last Container.beginTransaction(). |
void |
setConnection(java.sql.Connection connection)
Sets the connection to the DBMS. |
void |
updateObject(PObject obj)
Updates the given persistent object in the database. |
| Methods inherited from class de.mguennewig.pobjects.AbstractContainer |
|---|
createObject, deleteAll, getClassDecl, getClassDecls, getData, getDictionary, getObject, getQualifiedName, getSchema, getTableExpr, isStrictMode, makePersistent, newQuery, newQuery, newQuery, newQuery, newQuery, newQuery, newQuery, newQuery, notifyChange, setStrictMode, storeAll, supportsBoolean, supportsInherits, supportsLimitOffset, supportsOracleJoin, supportsSQL99Join, useArrayForLob, useStreamToInsertLob |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface de.mguennewig.pobjects.Container |
|---|
getCapabilities, getSequenceCurrentValue, getSequenceNextValue, insertObject |
| Constructor Detail |
|---|
public JdbcContainer(PObjDictionary dict,
java.lang.String schema)
public JdbcContainer(java.lang.String hostname,
java.lang.Integer port,
java.lang.String database,
java.lang.String username,
java.lang.String password,
PObjDictionary dict,
java.lang.String schema)
throws java.sql.SQLException
NOTE: Auto-commitment will be turned off which is normally turned on for JDBC.
hostname - The host name on which the DBMS runs. If null
it defaults to localhost.port - The port on which the DBMS listens. If null the
default port is used.database - The name of the database.username - The user name that should be used for authentication.password - The password that should be used for authentication.dict - schema -
java.sql.SQLException - if no connection to the database can be opened, or
an error occurred during initializationinitializeConnection()
public JdbcContainer(java.sql.Connection conn,
PObjDictionary dict,
java.lang.String schema)
throws java.sql.SQLException
NOTE: Auto-commitment will be turned off which is normally turned on for JDBC.
java.sql.SQLException - if any database error occurs during initialization.initializeConnection()| Method Detail |
|---|
public void close()
throws PObjSQLException
PObjSQLException
public PObject getObject(ClassDecl cdecl,
java.lang.String id)
PObject instance for the given
table expression without reading any data from the DB.
This version caches the database objects to save database queries.
getObject in interface ContainergetObject in class AbstractContainerContainer.getData(TableExpr),
Container.retrieveData(PObject)
public void beginTransaction()
throws PObjSQLException
beginTransaction in interface ContainerbeginTransaction in class AbstractContainerPObjSQLException - if the DBMS is unable to start a new transaction.
public void commitTransaction()
throws PObjSQLException
Container.beginTransaction().
If Container.isStrictMode() yields false then just a
warning for each dirty object is written, otherwise an exception is
raised.
commitTransaction in interface ContainercommitTransaction in class AbstractContainerPObjSQLException - if the DBMS in unable to finish the current
transaction by committing it or if an modified but unstored object is
detected while in strict mode.
public void rollbackTransaction()
throws PObjSQLException
Container.beginTransaction().
The in-memory data will be reverted also as far as possible.
rollbackTransaction in interface ContainerrollbackTransaction in class AbstractContainerPObjSQLException - if the DBMS is unable to stop the current
transaction by rolling back all made changes within it.PObject.revert()
public int deleteAll(ClassDecl te)
throws PObjSQLException,
PObjConstraintException
NOTE: The objects which represent a row of this table or refer
to rows within it aren't updated. So the best way to ensure consistency
is to finish the current active transaction before calling this method and
afterwards doing a Container.reset().
PObjSQLException - if any other database error occurs.
PObjConstraintException - if a database constraint will be violated.
public int deleteAll(ClassDecl cl,
Column fk,
java.lang.Object value)
throws PObjSQLException,
PObjConstraintException
fk equals the given value.
NOTE: The objects which represent a row of this table or refer
to rows within it aren't updated. So the best way to ensure consistency
is to finish the current active transaction before calling this method and
afterwards doing a Container.reset().
PObjSQLException - if any other database error occurs.
PObjConstraintException - if a database constraint will be violated.
public void deleteObject(PObject obj)
throws PObjConstraintException,
PObjSQLException
PObjConstraintException - if a database constraint will be violated.
PObjSQLException - if any other database error occurs.PObject.isPersistent()
public boolean deleteRecord(Record obj)
throws PObjConstraintException,
PObjSQLException
PObjConstraintException
PObjSQLExceptionpublic void reset()
Use this method to forget all changes made to any object.
NOTE: Any running transaction will be rolled back.
reset in interface Containerreset in class AbstractContainerContainer.rollbackTransaction()public EvalContext newEvalContext(int numColumns)
public Query newQuery()
public void retrieveData(PObject obj)
public boolean insertRecord(Record obj)
throws PObjConstraintException,
PObjSQLException
PObjConstraintException
PObjSQLException
public void updateObject(PObject obj)
throws PObjConstraintException,
PObjSQLException
PObjConstraintException - if a database constraint will be violated.
PObjSQLException - if any other database error occurs.PObject.isPersistent()
public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int scrollType,
int concurrType)
throws java.sql.SQLException
java.sql.SQLException
public void addArguments(java.sql.PreparedStatement statm,
SqlStatement sql,
java.lang.Object[] arguments)
throws PObjSQLException
PObjSQLException
public void addParameter(java.sql.PreparedStatement statm,
int pos,
Type t,
java.lang.Object value)
throws PObjSQLException
PObjSQLException
public abstract java.lang.String getConnectURL(java.lang.String hostname,
java.lang.Integer port,
java.lang.String database)
public java.util.Properties getConnectProperties()
public final java.sql.Connection getConnection()
public void setConnection(java.sql.Connection connection)
throws java.sql.SQLException
NOTE: Any transaction will be rolled back and the cache is cleared.
java.sql.SQLExceptionreset()public final ClassDecl mapPClassIdToClassDecl(java.lang.String id)
ClassDecl.
null if the id is unknown.
java.lang.UnsupportedOperationException - if DB supports INHERITS.AbstractContainer.getClassDecl(String),
registerClass(ClassDecl)public final java.lang.String mapClassDeclToPClassId(ClassDecl cd)
ClassDecl to the pclass id used in the
DBMS.
null if the id is unknown.
java.lang.UnsupportedOperationException - if DB supports INHERITS.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||