TZAbstractConnection Class Reference

Implements Abstract Database Connection. More...

Inheritance diagram for TZAbstractConnection:

TInterfacedObject IZConnection TZAdoConnection TZASAConnection TZDBLibConnection TZInterbase6Connection TZMySQLConnection TZOracleConnection TZPostgreSQLConnection TZSQLiteConnection

List of all members.

Public Member Functions

 ClearWarnings ()
 Clears all warnings reported for this Connection object.
 Close ()
 Releases a Connection's database and JDBC resources immediately instead of waiting for them to be automatically released.
 Commit ()
 Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection.
 CommitPrepared (const string transactionid)
IZNotification CreateNotification (const string Event)
 Creates an object to send/recieve notifications from SQL server.
IZSequence CreateSequence (const string Sequence, Integer BlockSize)
 Creates a sequence generator object.
IZStatement CreateStatement ()
 Creates a Statement object for sending SQL statements to the database.
IZStatement CreateStatementWithParams (TStrings Info)
 Creates a Statement object for sending SQL statements to the database.
String EscapeString (String Value)
 Escape a string so it's acceptable for the Connection's server.
Boolean GetAutoCommit ()
 Gets the current auto-commit state.
string GetCatalog ()
 Returns the Connection's current catalog name.
Integer GetClientVersion ()
 Gets the client's full version number.
IZDriver GetDriver ()
 Gets the parent ZDBC driver.
Integer GetHostVersion ()
 Gets the host's full version number.
IZDatabaseMetadata GetMetadata ()
 Gets the metadata regarding this connection's database.
TStrings GetParameters ()
 Gets a connection parameters.
TZTransactIsolationLevel GetTransactionIsolation ()
 Gets this Connection's current transaction isolation level.
EZSQLWarning GetWarnings ()
 Returns the first warning reported by calls on this Connection.
Boolean IsClosed ()
 Tests to see if a Connection is closed.
Boolean IsReadOnly ()
 Tests to see if the connection is in read-only mode.
string NativeSQL (const string SQL)
 Converts the given SQL statement into the system's native SQL grammar.
 Open ()
 Opens a connection to database server with specified parameters.
Integer PingServer ()
 Ping Current Connection's server, if client was disconnected, the connection is resumed.
IZCallableStatement PrepareCall (const string SQL)
 Creates a CallableStatement object for calling database stored procedures.
IZCallableStatement PrepareCallWithParams (const string SQL, TStrings Info)
 Creates a CallableStatement object for calling database stored procedures.
IZPreparedStatement PrepareStatement (const string SQL)
 Creates a PreparedStatement object for sending parameterized SQL statements to the database.
IZPreparedStatement PrepareStatementWithParams (const string SQL, TStrings Info)
 Creates a PreparedStatement object for sending parameterized SQL statements to the database.
 PrepareTransaction (const string transactionid)
 Rollback ()
 Drops all changes made since the previous commit/rollback and releases any database locks currently held by this Connection.
 RollbackPrepared (const string transactionid)
 SetAutoCommit (Boolean AutoCommit)
 Sets this connection's auto-commit mode.
 SetCatalog (const string Catalog)
 Sets a catalog name in order to select a subspace of this Connection's database in which to work.
 SetReadOnly (Boolean ReadOnly)
 Puts this connection in read-only mode as a hint to enable database optimizations.
 SetTransactionIsolation (TZTransactIsolationLevel Level)
 Attempts to change the transaction isolation level to the one given.
 TZAbstractConnection (IZDriver Driver, const string Url, const string HostName, Integer Port, const string Database, const string User, const string Password, TStrings Info, TContainedObject Metadata)
 Constructs this object and assignes the main properties.
 ~TZAbstractConnection ()
 Destroys this object and cleanups the memory.

Protected Member Functions

IZCallableStatement CreateCallableStatement (const string SQL, TStrings Info)
 Creates a callable statement object.
IZPreparedStatement CreatePreparedStatement (const string SQL, TStrings Info)
 Creates a prepared statement object.
IZStatement CreateRegularStatement (TStrings Info)
 Creates a regular statement object.
 RaiseUnsupportedException ()
 Raises unsupported operation exception.

Protected Attributes

Boolean AutoCommit
Boolean Closed
string Database
IZDriver Driver
string HostName
TStrings Info
string Password
Integer Port
Boolean ReadOnly
TZTransactIsolationLevel TransactIsolationLevel
string User

Private Attributes

Boolean FAutoCommit
Boolean FClosed
string FDatabase
IZDriver FDriver
string FHostName
TStrings FInfo
TContainedObject FMetadata
string FPassword
Integer FPort
Boolean FReadOnly
TZTransactIsolationLevel FTransactIsolationLevel
string FUser


Detailed Description

Implements Abstract Database Connection.

Definition at line 147 of file ZDbcConnection.pas.


Constructor & Destructor Documentation

TZAbstractConnection::TZAbstractConnection ( IZDriver  Driver,
const string  Url,
const string  HostName,
Integer  Port,
const string  Database,
const string  User,
const string  Password,
TStrings  Info,
TContainedObject  Metadata 
)

Constructs this object and assignes the main properties.

Parameters:
Driver a ZDBC driver interface.
Url a connection URL.
HostName a name of the host.
Port a port number (0 for default port).
Database a name pof the database.
User a user name.
Password a user password.
Info a string list with extra connection parameters.

Definition at line 711 of file ZDbcConnection.pas.

TZAbstractConnection::~TZAbstractConnection (  ) 

Destroys this object and cleanups the memory.

Definition at line 751 of file ZDbcConnection.pas.


Member Function Documentation

TZAbstractConnection::ClearWarnings (  ) 

Clears all warnings reported for this Connection object.

After a call to this method, the method getWarnings returns null until a new warning is reported for this Connection.

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, and TZDBLibConnection.

Definition at line 1386 of file ZDbcConnection.pas.

TZAbstractConnection::Close (  ) 

Releases a Connection's database and JDBC resources immediately instead of waiting for them to be automatically released.

Note: A Connection is automatically closed when it is garbage collected. Certain fatal errors also result in a closed Connection.

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, TZASAConnection, TZDBLibConnection, TZInterbase6Connection, TZMySQLConnection, TZOracleConnection, TZPostgreSQLConnection, and TZSQLiteConnection.

Definition at line 1182 of file ZDbcConnection.pas.

TZAbstractConnection::Commit (  ) 

Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection.

This method should be used only when auto-commit mode has been disabled.

See also:
setAutoCommit

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, TZASAConnection, TZDBLibConnection, TZInterbase6Connection, TZMySQLConnection, TZOracleConnection, TZPostgreSQLConnection, and TZSQLiteConnection.

Definition at line 1103 of file ZDbcConnection.pas.

TZAbstractConnection::CommitPrepared ( const string  transactionid  ) 

Reimplemented from IZConnection.

Reimplemented in TZPostgreSQLConnection.

Definition at line 1111 of file ZDbcConnection.pas.

IZCallableStatement TZAbstractConnection::CreateCallableStatement ( const string  SQL,
TStrings  Info 
) [protected]

Creates a callable statement object.

Parameters:
SQL a SQL query string.
Info a statement parameters.
Returns:
a created statement.

Reimplemented in TZAdoConnection, TZASAConnection, TZDBLibConnection, and TZInterbase6Connection.

Definition at line 992 of file ZDbcConnection.pas.

IZNotification TZAbstractConnection::CreateNotification ( const string  Event  ) 

Creates an object to send/recieve notifications from SQL server.

Parameters:
Event an event name.
Returns:
a created notification object.

Reimplemented from IZConnection.

Definition at line 1008 of file ZDbcConnection.pas.

IZPreparedStatement TZAbstractConnection::CreatePreparedStatement ( const string  SQL,
TStrings  Info 
) [protected]

Creates a prepared statement object.

Parameters:
SQL a SQL query string.
Info a statement parameters.
Returns:
a created statement.

Reimplemented in TZAdoConnection, TZASAConnection, TZDBLibConnection, TZInterbase6Connection, TZMySQLConnection, TZOracleConnection, TZPostgreSQLConnection, and TZSQLiteConnection.

Definition at line 916 of file ZDbcConnection.pas.

IZStatement TZAbstractConnection::CreateRegularStatement ( TStrings  Info  )  [protected]

Creates a regular statement object.

Parameters:
SQL a SQL query string.
Info a statement parameters.
Returns:
a created statement.

Reimplemented in TZAdoConnection, TZASAConnection, TZDBLibConnection, TZInterbase6Connection, TZMySQLConnection, TZOracleConnection, TZPostgreSQLConnection, and TZSQLiteConnection.

Definition at line 835 of file ZDbcConnection.pas.

IZSequence TZAbstractConnection::CreateSequence ( const string  Sequence,
Integer  BlockSize 
)

Creates a sequence generator object.

Parameters:
Sequence a name of the sequence generator.
BlockSize a number of unique keys requested in one trip to SQL server.
Returns:
a created sequence object.

Reimplemented from IZConnection.

Reimplemented in TZInterbase6Connection, TZOracleConnection, and TZPostgreSQLConnection.

Definition at line 1024 of file ZDbcConnection.pas.

IZStatement TZAbstractConnection::CreateStatement (  ) 

Creates a Statement object for sending SQL statements to the database.

SQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it is more efficient to use a PreparedStatement object.

Result sets created using the returned Statement object will by default have forward-only type and read-only concurrency.

Returns:
a new Statement object

Reimplemented from IZConnection.

Definition at line 797 of file ZDbcConnection.pas.

IZStatement TZAbstractConnection::CreateStatementWithParams ( TStrings  Info  ) 

Creates a Statement object for sending SQL statements to the database.

SQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it is more efficient to use a PreparedStatement object.

Result sets created using the returned Statement object will by default have forward-only type and read-only concurrency.

Parameters:
Info a statement parameters.
Returns:
a new Statement object

Reimplemented from IZConnection.

Definition at line 820 of file ZDbcConnection.pas.

String TZAbstractConnection::EscapeString ( String  Value  ) 

Escape a string so it's acceptable for the Connection's server.

Parameters:
value string that should be escaped
Returns:
Escaped string

Reimplemented from IZConnection.

Reimplemented in TZMySQLConnection.

Definition at line 1163 of file ZDbcConnection.pas.

Boolean TZAbstractConnection::GetAutoCommit (  ) 

Gets the current auto-commit state.

Returns:
the current state of auto-commit mode
See also:
setAutoCommit

Reimplemented from IZConnection.

Definition at line 1088 of file ZDbcConnection.pas.

string TZAbstractConnection::GetCatalog (  ) 

Returns the Connection's current catalog name.

Returns:
the current catalog name or null

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, TZDBLibConnection, TZMySQLConnection, TZOracleConnection, and TZSQLiteConnection.

Definition at line 1326 of file ZDbcConnection.pas.

Integer TZAbstractConnection::GetClientVersion (  ) 

Gets the client's full version number.

Initially this should be 0. The format of the version resturned must be XYYYZZZ where X = Major version YYY = Minor version ZZZ = Sub version

Returns:
this clients's full version number

Reimplemented from IZConnection.

Reimplemented in TZMySQLConnection.

Definition at line 1252 of file ZDbcConnection.pas.

IZDriver TZAbstractConnection::GetDriver (  ) 

Gets the parent ZDBC driver.

Returns:
the parent ZDBC driver interface.

Reimplemented from IZConnection.

Definition at line 1206 of file ZDbcConnection.pas.

Integer TZAbstractConnection::GetHostVersion (  ) 

Gets the host's full version number.

Initially this should be 0. The format of the version returned must be XYYYZZZ where X = Major version YYY = Minor version ZZZ = Sub version

Returns:
this server's full version number

Reimplemented from IZConnection.

Reimplemented in TZMySQLConnection, and TZPostgreSQLConnection.

Definition at line 1268 of file ZDbcConnection.pas.

IZDatabaseMetadata TZAbstractConnection::GetMetadata (  ) 

Gets the metadata regarding this connection's database.

A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on. This information is made available through a DatabaseMetaData object.

Returns:
a DatabaseMetaData object for this Connection

Reimplemented from IZConnection.

Definition at line 1224 of file ZDbcConnection.pas.

TStrings TZAbstractConnection::GetParameters (  ) 

Gets a connection parameters.

Returns:
a list with connection parameters.

Reimplemented from IZConnection.

Definition at line 1236 of file ZDbcConnection.pas.

TZTransactIsolationLevel TZAbstractConnection::GetTransactionIsolation (  ) 

Gets this Connection's current transaction isolation level.

Returns:
the current TRANSACTION_* mode value

Reimplemented from IZConnection.

Definition at line 1359 of file ZDbcConnection.pas.

EZSQLWarning TZAbstractConnection::GetWarnings (  ) 

Returns the first warning reported by calls on this Connection.

Note: Subsequent warnings will be chained to this SQLWarning.

Returns:
the first SQLWarning or null

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, and TZDBLibConnection.

Definition at line 1373 of file ZDbcConnection.pas.

Boolean TZAbstractConnection::IsClosed (  ) 

Tests to see if a Connection is closed.

Returns:
true if the connection is closed; false if it's still open

Reimplemented from IZConnection.

Definition at line 1194 of file ZDbcConnection.pas.

Boolean TZAbstractConnection::IsReadOnly (  ) 

Tests to see if the connection is in read-only mode.

Returns:
true if connection is read-only and false otherwise

Reimplemented from IZConnection.

Definition at line 1300 of file ZDbcConnection.pas.

string TZAbstractConnection::NativeSQL ( const string  SQL  ) 

Converts the given SQL statement into the system's native SQL grammar.

A driver may convert the JDBC sql grammar into its system's native SQL grammar prior to sending it; this method returns the native form of the statement that the driver would have sent.

Parameters:
sql a SQL statement that may contain one or more '?' parameter placeholders
Returns:
the native form of this statement

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, and TZDBLibConnection.

Definition at line 1045 of file ZDbcConnection.pas.

TZAbstractConnection::Open (  ) 

Opens a connection to database server with specified parameters.

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, TZASAConnection, TZDBLibConnection, TZInterbase6Connection, TZMySQLConnection, TZOracleConnection, TZPostgreSQLConnection, and TZSQLiteConnection.

Definition at line 765 of file ZDbcConnection.pas.

Integer TZAbstractConnection::PingServer (  ) 

Ping Current Connection's server, if client was disconnected, the connection is resumed.

Returns:
0 if succesfull or error code if any error occurs

Reimplemented from IZConnection.

Reimplemented in TZInterbase6Connection, TZMySQLConnection, and TZPostgreSQLConnection.

Definition at line 1149 of file ZDbcConnection.pas.

IZCallableStatement TZAbstractConnection::PrepareCall ( const string  SQL  ) 

Creates a CallableStatement object for calling database stored procedures.

The CallableStatement object provides methods for setting up its IN and OUT parameters, and methods for executing the call to a stored procedure.

Note: This method is optimized for handling stored procedure call statements. Some drivers may send the call statement to the database when the method prepareCall is done; others may wait until the CallableStatement object is executed. This has no direct effect on users; however, it does affect which method throws certain SQLExceptions.

Result sets created using the returned CallableStatement will have forward-only type and read-only concurrency, by default.

Parameters:
sql a SQL statement that may contain one or more '?' parameter placeholders. Typically this statement is a JDBC function call escape string.
Returns:
a new CallableStatement object containing the pre-compiled SQL statement

Reimplemented from IZConnection.

Definition at line 953 of file ZDbcConnection.pas.

IZCallableStatement TZAbstractConnection::PrepareCallWithParams ( const string  SQL,
TStrings  Info 
)

Creates a CallableStatement object for calling database stored procedures.

The CallableStatement object provides methods for setting up its IN and OUT parameters, and methods for executing the call to a stored procedure.

Parameters:
SQL a SQL statement that may contain one or more '?' parameter placeholders. Typically this statement is a JDBC function call escape string.
Info a statement parameters.
Returns:
a new CallableStatement object containing the pre-compiled SQL statement

Reimplemented from IZConnection.

Definition at line 976 of file ZDbcConnection.pas.

IZPreparedStatement TZAbstractConnection::PrepareStatement ( const string  SQL  ) 

Creates a PreparedStatement object for sending parameterized SQL statements to the database.

A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.

Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement is executed. This has no direct effect on users; however, it does affect which method throws certain SQLExceptions.

Result sets created using the returned PreparedStatement will have forward-only type and read-only concurrency, by default.

Parameters:
sql a SQL statement that may contain one or more '?' IN parameter placeholders
Returns:
a new PreparedStatement object containing the pre-compiled statement

Reimplemented from IZConnection.

Definition at line 872 of file ZDbcConnection.pas.

IZPreparedStatement TZAbstractConnection::PrepareStatementWithParams ( const string  SQL,
TStrings  Info 
)

Creates a PreparedStatement object for sending parameterized SQL statements to the database.

Parameters:
SQL a SQL statement that may contain one or more '?' IN parameter placeholders
Info a statement parameters.
Returns:
a new PreparedStatement object containing the pre-compiled statement

Reimplemented from IZConnection.

Definition at line 891 of file ZDbcConnection.pas.

TZAbstractConnection::PrepareTransaction ( const string  transactionid  ) 

Reimplemented from IZConnection.

Reimplemented in TZPostgreSQLConnection.

Definition at line 901 of file ZDbcConnection.pas.

References P.

TZAbstractConnection::RaiseUnsupportedException (  )  [protected]

Raises unsupported operation exception.

Definition at line 776 of file ZDbcConnection.pas.

TZAbstractConnection::Rollback (  ) 

Drops all changes made since the previous commit/rollback and releases any database locks currently held by this Connection.

This method should be used only when auto- commit has been disabled.

See also:
setAutoCommit

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, TZASAConnection, TZDBLibConnection, TZInterbase6Connection, TZMySQLConnection, TZOracleConnection, TZPostgreSQLConnection, and TZSQLiteConnection.

Definition at line 1127 of file ZDbcConnection.pas.

TZAbstractConnection::RollbackPrepared ( const string  transactionid  ) 

Reimplemented from IZConnection.

Reimplemented in TZPostgreSQLConnection.

Definition at line 1135 of file ZDbcConnection.pas.

TZAbstractConnection::SetAutoCommit ( Boolean  AutoCommit  ) 

Sets this connection's auto-commit mode.

If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method 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. In advanced cases, a single statement may return multiple results as well as output parameter values. In these cases the commit occurs when all results and output parameter values have been retrieved.

Parameters:
autoCommit true enables auto-commit; false disables auto-commit.

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, TZDBLibConnection, and TZMySQLConnection.

Definition at line 1074 of file ZDbcConnection.pas.

TZAbstractConnection::SetCatalog ( const string  Catalog  ) 

Sets a catalog name in order to select a subspace of this Connection's database in which to work.

If the driver does not support catalogs, it will silently ignore this request.

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, TZDBLibConnection, TZMySQLConnection, TZOracleConnection, and TZSQLiteConnection.

Definition at line 1314 of file ZDbcConnection.pas.

TZAbstractConnection::SetReadOnly ( Boolean  ReadOnly  ) 

Puts this connection in read-only mode as a hint to enable database optimizations.

Note: This method cannot be called while in the middle of a transaction.

Parameters:
readOnly true enables read-only mode; false disables read-only mode.

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, and TZDBLibConnection.

Definition at line 1287 of file ZDbcConnection.pas.

TZAbstractConnection::SetTransactionIsolation ( TZTransactIsolationLevel  Level  ) 

Attempts to change the transaction isolation level to the one given.

The constants defined in the interface Connection are the possible transaction isolation levels.

Note: This method cannot be called while in the middle of a transaction.

Parameters:
level one of the TRANSACTION_* isolation values with the exception of TRANSACTION_NONE; some databases may not support other values
See also:
DatabaseMetaData::supportsTransactionIsolationLevel

Reimplemented from IZConnection.

Reimplemented in TZAdoConnection, TZDBLibConnection, TZMySQLConnection, TZOracleConnection, TZPostgreSQLConnection, and TZSQLiteConnection.

Definition at line 1346 of file ZDbcConnection.pas.


Member Data Documentation

Boolean TZAbstractConnection::AutoCommit [protected]

See also:
FAutoCommit For reading

FAutoCommit For writing

Definition at line 221 of file ZDbcConnection.pas.

Boolean TZAbstractConnection::Closed [protected]

See also:
FClosed For reading

FClosed For writing

Definition at line 231 of file ZDbcConnection.pas.

string TZAbstractConnection::Database [protected]

See also:
FDatabase For reading

FDatabase For writing

Definition at line 209 of file ZDbcConnection.pas.

See also:
FDriver For reading

FDriver For writing

Definition at line 197 of file ZDbcConnection.pas.

Definition at line 166 of file ZDbcConnection.pas.

Boolean TZAbstractConnection::FClosed [private]

Definition at line 172 of file ZDbcConnection.pas.

Definition at line 158 of file ZDbcConnection.pas.

Definition at line 152 of file ZDbcConnection.pas.

Definition at line 154 of file ZDbcConnection.pas.

TStrings TZAbstractConnection::FInfo [private]

Definition at line 164 of file ZDbcConnection.pas.

TContainedObject TZAbstractConnection::FMetadata [private]

Definition at line 174 of file ZDbcConnection.pas.

Definition at line 162 of file ZDbcConnection.pas.

Integer TZAbstractConnection::FPort [private]

Definition at line 156 of file ZDbcConnection.pas.

Definition at line 168 of file ZDbcConnection.pas.

Definition at line 170 of file ZDbcConnection.pas.

string TZAbstractConnection::FUser [private]

Definition at line 160 of file ZDbcConnection.pas.

string TZAbstractConnection::HostName [protected]

See also:
FHostName For reading

FHostName For writing

Definition at line 203 of file ZDbcConnection.pas.

TStrings TZAbstractConnection::Info [protected]

See also:
FInfo For reading

Definition at line 218 of file ZDbcConnection.pas.

string TZAbstractConnection::Password [protected]

See also:
FPassword For reading

FPassword For writing

Definition at line 215 of file ZDbcConnection.pas.

Integer TZAbstractConnection::Port [protected]

See also:
FPort For reading

FPort For writing

Definition at line 206 of file ZDbcConnection.pas.

Boolean TZAbstractConnection::ReadOnly [protected]

See also:
FReadOnly For reading

FReadOnly For writing

Definition at line 224 of file ZDbcConnection.pas.

See also:
FTransactIsolationLevel For reading

FTransactIsolationLevel For writing

Definition at line 228 of file ZDbcConnection.pas.

string TZAbstractConnection::User [protected]

See also:
FUser For reading

FUser For writing

Definition at line 212 of file ZDbcConnection.pas.


The documentation for this class was generated from the following file:

Generated on Wed Dec 30 08:42:46 2009 for zeoslib by  doxygen 1.5.7.1