00001 {*********************************************************}
00002 { }
00003 { Zeos Database Objects }
00004 { Abstract Database Connectivity Classes }
00005 { }
00006 { Originally written by Sergey Seroukhov }
00007 { }
00008 {*********************************************************}
00009
00010 {@********************************************************}
00011 { Copyright (c) 1999-2006 Zeos Development Group }
00012 { }
00013 { License Agreement: }
00014 { }
00015 { This library is distributed in the hope that it will be }
00016 { useful, but WITHOUT ANY WARRANTY; without even the }
00017 { implied warranty of MERCHANTABILITY or FITNESS FOR }
00018 { A PARTICULAR PURPOSE. See the GNU Lesser General }
00019 { Public License for more details. }
00020 { }
00021 { The source code of the ZEOS Libraries and packages are }
00022 { distributed under the Library GNU General Public }
00023 { License (see the file COPYING / COPYING.ZEOS) }
00024 { with the following modification: }
00025 { As a special exception, the copyright holders of this }
00026 { library give you permission to link this library with }
00027 { independent modules to produce an executable, }
00028 { regardless of the license terms of these independent }
00029 { modules, and to copy and distribute the resulting }
00030 { executable under terms of your choice, provided that }
00031 { you also meet, for each linked independent module, }
00032 { the terms and conditions of the license of that module. }
00033 { An independent module is a module which is not derived }
00034 { from or based on this library. If you modify this }
00035 { library, you may extend this exception to your version }
00036 { of the library, but you are not obligated to do so. }
00037 { If you do not wish to do so, delete this exception }
00038 { statement from your version. }
00039 { }
00040 { }
00041 { The project web site is located on: }
00042 { http:
00043 { http:
00044 { svn:
00045 { }
00046 { http:
00047 { http:
00048 { }
00049 { }
00050 { }
00051 { Zeos Development Group. }
00052 {********************************************************@}
00053
00054 unit ZDbcConnection;
00055
00056 interface
00057
00058 {$I ZDbc.inc}
00059
00060 uses
00061 {$IFNDEF VER130BELOW}
00062 Types,
00063 {$ENDIF}
00064 {$IFDEF VER130BELOW}
00065 {$IFDEF WIN32}
00066 Comobj,
00067 {$ENDIF}
00068 {$ENDIF}
00069 Classes, SysUtils, ZClasses, ZDbcIntfs, ZTokenizer, ZCompatibility,
00070 ZGenericSqlToken, ZGenericSqlAnalyser;
00071
00072 type
00073
00074 {** Implements Abstract Database Driver. }
00075 TZAbstractDriver = class(TInterfacedObject, IZDriver)
00076 private
00077 FTokenizer: IZTokenizer;
00078 FAnalyser: IZStatementAnalyser;
00079
00080 protected
00081 property Tokenizer: IZTokenizer read FTokenizer write FTokenizer;
00082 property Analyser: IZStatementAnalyser read FAnalyser write FAnalyser;
00083
00084 public
00085 constructor Create;
00086 destructor Destroy; override;
00087
00088 function GetSupportedProtocols: TStringDynArray; virtual; abstract;
00089 function Connect(const Url: string; Info: TStrings): IZConnection; virtual;
00090 function AcceptsURL(const Url: string): Boolean; virtual;
00091
00092 function GetPropertyInfo(const Url: string; Info: TStrings): TStrings; virtual;
00093 function GetMajorVersion: Integer; virtual;
00094 function GetMinorVersion: Integer; virtual;
00095 function GetSubVersion: Integer; virtual;
00096 function GetTokenizer: IZTokenizer; virtual;
00097 function GetStatementAnalyser: IZStatementAnalyser; virtual;
00098 function GetClientVersion(const Url: string): Integer; virtual;
00099 end;
00100
00101 {** Implements Abstract Database Connection. }
00102 TZAbstractConnection = class(TInterfacedObject, IZConnection)
00103 private
00104 FDriver: IZDriver;
00105 FHostName: string;
00106 FPort: Integer;
00107 FDatabase: string;
00108 FUser: string;
00109 FPassword: string;
00110 FInfo: TStrings;
00111 FAutoCommit: Boolean;
00112 FReadOnly: Boolean;
00113 FTransactIsolationLevel: TZTransactIsolationLevel;
00114 FClosed: Boolean;
00115 FMetadata: TContainedObject;
00116 protected
00117 procedure RaiseUnsupportedException;
00118
00119 function CreateRegularStatement(Info: TStrings): IZStatement;
00120 virtual;
00121 function CreatePreparedStatement(const SQL: string; Info: TStrings):
00122 IZPreparedStatement; virtual;
00123 function CreateCallableStatement(const SQL: string; Info: TStrings):
00124 IZCallableStatement; virtual;
00125
00126 property Driver: IZDriver read FDriver write FDriver;
00127 property HostName: string read FHostName write FHostName;
00128 property Port: Integer read FPort write FPort;
00129 property Database: string read FDatabase write FDatabase;
00130 property User: string read FUser write FUser;
00131 property Password: string read FPassword write FPassword;
00132 property Info: TStrings read FInfo;
00133 property AutoCommit: Boolean read FAutoCommit write FAutoCommit;
00134 property ReadOnly: Boolean read FReadOnly write FReadOnly;
00135 property TransactIsolationLevel: TZTransactIsolationLevel
00136 read FTransactIsolationLevel write FTransactIsolationLevel;
00137 property Closed: Boolean read FClosed write FClosed;
00138 public
00139 constructor Create(Driver: IZDriver; const Url: string; const HostName: string;
00140 Port: Integer; const Database: string; const User: string; const Password: string;
00141 Info: TStrings; Metadata: TContainedObject);
00142 destructor Destroy; override;
00143
00144 function CreateStatement: IZStatement;
00145 function PrepareStatement(const SQL: string): IZPreparedStatement;
00146 function PrepareCall(const SQL: string): IZCallableStatement;
00147
00148 function CreateStatementWithParams(Info: TStrings): IZStatement;
00149 function PrepareStatementWithParams(const SQL: string; Info: TStrings):
00150 IZPreparedStatement;
00151 function PrepareCallWithParams(const SQL: string; Info: TStrings):
00152 IZCallableStatement;
00153
00154 function CreateNotification(const Event: string): IZNotification; virtual;
00155 function CreateSequence(const Sequence: string; BlockSize: Integer):
00156 IZSequence; virtual;
00157
00158 function NativeSQL(const SQL: string): string; virtual;
00159
00160 procedure SetAutoCommit(AutoCommit: Boolean); virtual;
00161 function GetAutoCommit: Boolean; virtual;
00162
00163 procedure Commit; virtual;
00164 procedure Rollback; virtual;
00165
00166
00167 procedure PrepareTransaction(const transactionid: string);virtual;
00168 procedure CommitPrepared(const transactionid: string);virtual;
00169 procedure RollbackPrepared(const transactionid: string);virtual;
00170
00171
00172 function PingServer: Integer; virtual;
00173 function EscapeString(Value : String) : String; virtual;
00174
00175 procedure Open; virtual;
00176 procedure Close; virtual;
00177 function IsClosed: Boolean; virtual;
00178
00179 function GetDriver: IZDriver;
00180 function GetMetadata: IZDatabaseMetadata;
00181 function GetParameters: TStrings;
00182 {ADDED by fduenas 15-06-2006}
00183 function GetClientVersion: Integer; virtual;
00184 function GetHostVersion: Integer; virtual;
00185 {END ADDED by fduenas 15-06-2006}
00186 procedure SetReadOnly(ReadOnly: Boolean); virtual;
00187 function IsReadOnly: Boolean; virtual;
00188
00189 procedure SetCatalog(const Catalog: string); virtual;
00190 function GetCatalog: string; virtual;
00191
00192 procedure SetTransactionIsolation(Level: TZTransactIsolationLevel); virtual;
00193 function GetTransactionIsolation: TZTransactIsolationLevel; virtual;
00194
00195 function GetWarnings: EZSQLWarning; virtual;
00196 procedure ClearWarnings; virtual;
00197 end;
00198
00199 {** Implements Abstract Database notification. }
00200 TZAbstractNotification = class(TInterfacedObject, IZNotification)
00201 private
00202 FEventName: string;
00203 FConnection: IZConnection;
00204 protected
00205 property EventName: string read FEventName write FEventName;
00206 property Connection: IZConnection read FConnection write FConnection;
00207 public
00208 constructor Create(Connection: IZConnection; EventName: string);
00209 function GetEvent: string;
00210 procedure Listen; virtual;
00211 procedure Unlisten; virtual;
00212 procedure DoNotify; virtual;
00213 function CheckEvents: string; virtual;
00214
00215 function GetConnection: IZConnection; virtual;
00216 end;
00217
00218 {** Implements Abstract Sequence generator. }
00219 TZAbstractSequence = class(TInterfacedObject, IZSequence)
00220 private
00221 FName: string;
00222 FBlockSize: Integer;
00223 FConnection: IZConnection;
00224 protected
00225 function GetName: string; virtual;
00226 function GetBlockSize: Integer; virtual;
00227 procedure SetName(const Value: string); virtual;
00228 procedure SetBlockSize(const Value: Integer); virtual;
00229 property Connection: IZConnection read FConnection write FConnection;
00230 public
00231 constructor Create(Connection: IZConnection; Name: string;
00232 BlockSize: Integer);
00233
00234 function GetCurrentValue: Int64; virtual;
00235 function GetNextValue: Int64; virtual;
00236
00237 function GetCurrentValueSQL: string; virtual; abstract;
00238 function GetNextValueSQL: string; virtual; abstract;
00239
00240 function GetConnection: IZConnection; virtual;
00241
00242 property Name: string read GetName write SetName;
00243 property BlockSize: Integer read GetBlockSize write SetBlockSize;
00244 end;
00245
00246 implementation
00247
00248 uses ZMessages, ZSysUtils, ZDbcMetadata;
00249
00250 { TZAbstractDriver }
00251
00252 {**
00253 Constructs this object with default properties.
00254 }
00255 constructor TZAbstractDriver.Create;
00256 begin
00257 end;
00258
00259 {**
00260 Destroys this object and cleanups the memory.
00261 }
00262 destructor TZAbstractDriver.Destroy;
00263 begin
00264 inherited Destroy;
00265 end;
00266
00267 {**
00268 Attempts to make a database connection to the given URL.
00269 The driver should return "null" if it realizes it is the wrong kind
00270 of driver to connect to the given URL. This will be common, as when
00271 the JDBC driver manager is asked to connect to a given URL it passes
00272 the URL to each loaded driver in turn.
00273
00274 <P>The driver should raise a SQLException if it is the right
00275 driver to connect to the given URL, but has trouble connecting to
00276 the database.
00277
00278 <P>The java.util.Properties argument can be used to passed arbitrary
00279 string tag/value pairs as connection arguments.
00280 Normally at least "user" and "password" properties should be
00281 included in the Properties.
00282
00283 @param url the URL of the database to which to connect
00284 @param info a list of arbitrary string tag/value pairs as
00285 connection arguments. Normally at least a "user" and
00286 "password" property should be included.
00287 @return a <code>Connection</code> object that represents a
00288 connection to the URL
00289 }
00290 function TZAbstractDriver.Connect(const Url: string; Info: TStrings): IZConnection;
00291 begin
00292 Result := nil;
00293 end;
00294
00295 {**
00296 Returns true if the driver thinks that it can open a connection
00297 to the given URL. Typically drivers will return true if they
00298 understand the subprotocol specified in the URL and false if
00299 they don't.
00300 @param url the URL of the database
00301 @return true if this driver can connect to the given URL
00302 }
00303 function TZAbstractDriver.AcceptsURL(const Url: string): Boolean;
00304 var
00305 I: Integer;
00306 Protocols: TStringDynArray;
00307 begin
00308 Result := False;
00309 Protocols := GetSupportedProtocols;
00310 for I := Low(Protocols) to High(Protocols) do
00311 begin
00312 Result := StartsWith(Url, Format('zdbc:%s:', [Protocols[I]]));
00313 if Result then
00314 Break;
00315 end;
00316 end;
00317
00318 {**
00319 Gets information about the possible properties for this driver.
00320 <p>The getPropertyInfo method is intended to allow a generic GUI tool to
00321 discover what properties it should prompt a human for in order to get
00322 enough information to connect to a database. Note that depending on
00323 the values the human has supplied so far, additional values may become
00324 necessary, so it may be necessary to iterate though several calls
00325 to getPropertyInfo.
00326
00327 @param url the URL of the database to which to connect
00328 @param info a proposed list of tag/value pairs that will be sent on
00329 connect open
00330 @return an array of DriverPropertyInfo objects describing possible
00331 properties. This array may be an empty array if no properties
00332 are required.
00333 }
00334 function TZAbstractDriver.GetPropertyInfo(const Url: string; Info: TStrings): TStrings;
00335 begin
00336 Result := nil;
00337 end;
00338
00339 {**
00340 Gets the driver's major version number. Initially this should be 1.
00341 @return this driver's major version number
00342 }
00343 function TZAbstractDriver.GetMajorVersion: Integer;
00344 begin
00345 Result := 1;
00346 end;
00347
00348 {**
00349 Gets the driver's minor version number. Initially this should be 0.
00350 @return this driver's minor version number
00351 }
00352 function TZAbstractDriver.GetMinorVersion: Integer;
00353 begin
00354 Result := 0;
00355 end;
00356
00357 {**
00358 Gets the driver's sub version (revision) number. Initially this should be 0.
00359 @return this driver's sub version number
00360 }
00361 function TZAbstractDriver.GetSubVersion: Integer;
00362 begin
00363 Result := 0;
00364 end;
00365 {**
00366 Creates a generic statement analyser object.
00367 @returns a generic statement analyser object.
00368 }
00369 function TZAbstractDriver.GetStatementAnalyser: IZStatementAnalyser;
00370 begin
00371 if Analyser = nil then
00372 Analyser := TZGenericStatementAnalyser.Create;
00373 Result := Analyser;
00374 end;
00375
00376 {**
00377 Creates a generic tokenizer object.
00378 @returns a created generic tokenizer object.
00379 }
00380 function TZAbstractDriver.GetTokenizer: IZTokenizer;
00381 begin
00382 if Tokenizer = nil then
00383 Tokenizer := TZGenericSQLTokenizer.Create;
00384 Result := Tokenizer;
00385 end;
00386
00387 {**
00388 Returns the version of the plain driver library that will be used to open a connection
00389 to the given URL.
00390 @param url the URL of the database
00391 @return the version number of the plain driver library for the give URL
00392 }
00393 function TZAbstractDriver.GetClientVersion(const Url: string): Integer;
00394 begin
00395 Result := 0;
00396 end;
00397
00398 { TZAbstractConnection }
00399
00400 {**
00401 Constructs this object and assignes the main properties.
00402 @param Driver a ZDBC driver interface.
00403 @param Url a connection URL.
00404 @param HostName a name of the host.
00405 @param Port a port number (0 for default port).
00406 @param Database a name pof the database.
00407 @param User a user name.
00408 @param Password a user password.
00409 @param Info a string list with extra connection parameters.
00410 }
00411 constructor TZAbstractConnection.Create(Driver: IZDriver; const Url: string;
00412 const HostName: string; Port: Integer; const Database: string; const User: string;
00413 const Password: string; Info: TStrings; Metadata: TContainedObject);
00414 begin
00415 FDriver := Driver;
00416 FHostName := HostName;
00417 FPort := Port;
00418 FDatabase := Database;
00419 FMetadata := Metadata;
00420
00421 FInfo := TStringList.Create;
00422 if Info <> nil then
00423 FInfo.AddStrings(Info);
00424
00425 if User <> '' then
00426 FUser := User
00427 else FUser := FInfo.Values['username'];
00428 if Password <> '' then
00429 FPassword := Password
00430 else FPassword := FInfo.Values['password'];
00431
00432 FAutoCommit := True;
00433 FClosed := True;
00434 FReadOnly := True;
00435 FTransactIsolationLevel := tiNone;
00436 end;
00437
00438 {**
00439 Destroys this object and cleanups the memory.
00440 }
00441 destructor TZAbstractConnection.Destroy;
00442 begin
00443 if not FClosed then Close;
00444 FInfo.Free;
00445 FMetadata.Free;
00446 inherited Destroy;
00447 end;
00448
00449 {**
00450 Opens a connection to database server with specified parameters.
00451 }
00452 procedure TZAbstractConnection.Open;
00453 begin
00454 FClosed := False;
00455 end;
00456
00457 {**
00458 Raises unsupported operation exception.
00459 }
00460 procedure TZAbstractConnection.RaiseUnsupportedException;
00461 begin
00462 raise EZSQLException.Create(SUnsupportedOperation);
00463 end;
00464
00465 {**
00466 Creates a <code>Statement</code> object for sending
00467 SQL statements to the database.
00468 SQL statements without parameters are normally
00469 executed using Statement objects. If the same SQL statement
00470 is executed many times, it is more efficient to use a
00471 <code>PreparedStatement</code> object.
00472 <P>
00473 Result sets created using the returned <code>Statement</code>
00474 object will by default have forward-only type and read-only concurrency.
00475
00476 @return a new Statement object
00477 }
00478 function TZAbstractConnection.CreateStatement: IZStatement;
00479 begin
00480 Result := CreateRegularStatement(nil);
00481 end;
00482
00483 {**
00484 Creates a <code>Statement</code> object for sending
00485 SQL statements to the database.
00486 SQL statements without parameters are normally
00487 executed using Statement objects. If the same SQL statement
00488 is executed many times, it is more efficient to use a
00489 <code>PreparedStatement</code> object.
00490 <P>
00491 Result sets created using the returned <code>Statement</code>
00492 object will by default have forward-only type and read-only concurrency.
00493
00494 @param Info a statement parameters.
00495 @return a new Statement object
00496 }
00497 function TZAbstractConnection.CreateStatementWithParams(Info: TStrings):
00498 IZStatement;
00499 begin
00500 Result := CreateRegularStatement(Info);
00501 end;
00502
00503 {**
00504 Creates a regular statement object.
00505 @param SQL a SQL query string.
00506 @param Info a statement parameters.
00507 @returns a created statement.
00508 }
00509 function TZAbstractConnection.CreateRegularStatement(
00510 Info: TStrings): IZStatement;
00511 begin
00512 Result := nil;
00513 RaiseUnsupportedException;
00514 end;
00515
00516 {**
00517 Creates a <code>PreparedStatement</code> object for sending
00518 parameterized SQL statements to the database.
00519
00520 A SQL statement with or without IN parameters can be
00521 pre-compiled and stored in a PreparedStatement object. This
00522 object can then be used to efficiently execute this statement
00523 multiple times.
00524
00525 <P><B>Note:</B> This method is optimized for handling
00526 parametric SQL statements that benefit from precompilation. If
00527 the driver supports precompilation,
00528 the method <code>prepareStatement</code> will send
00529 the statement to the database for precompilation. Some drivers
00530 may not support precompilation. In this case, the statement may
00531 not be sent to the database until the <code>PreparedStatement</code> is
00532 executed. This has no direct effect on users; however, it does
00533 affect which method throws certain SQLExceptions.
00534
00535 Result sets created using the returned PreparedStatement will have
00536 forward-only type and read-only concurrency, by default.
00537
00538 @param sql a SQL statement that may contain one or more '?' IN
00539 parameter placeholders
00540 @return a new PreparedStatement object containing the
00541 pre-compiled statement
00542 }
00543 function TZAbstractConnection.PrepareStatement(const SQL: string): IZPreparedStatement;
00544 begin
00545 Result := CreatePreparedStatement(SQL, nil);
00546 end;
00547
00548 {**
00549 Creates a <code>PreparedStatement</code> object for sending
00550 parameterized SQL statements to the database.
00551
00552 @param SQL a SQL statement that may contain one or more '?' IN
00553 parameter placeholders
00554 @param Info a statement parameters.
00555 @return a new PreparedStatement object containing the
00556 pre-compiled statement
00557 }
00558 function TZAbstractConnection.PrepareStatementWithParams(const SQL: string;
00559 Info: TStrings): IZPreparedStatement;
00560 begin
00561 Result := CreatePreparedStatement(SQL, Info);
00562 end;
00563
00564 procedure TZAbstractConnection.PrepareTransaction(const transactionid: string);
00565 begin
00566 RaiseUnsupportedException;
00567 end;
00568
00569 {**
00570 Creates a prepared statement object.
00571 @param SQL a SQL query string.
00572 @param Info a statement parameters.
00573 @returns a created statement.
00574 }
00575 function TZAbstractConnection.CreatePreparedStatement(const SQL: string;
00576 Info: TStrings): IZPreparedStatement;
00577 begin
00578 Result := nil;
00579 RaiseUnsupportedException;
00580 end;
00581
00582 {**
00583 Creates a <code>CallableStatement</code> object for calling
00584 database stored procedures.
00585 The <code>CallableStatement</code> object provides
00586 methods for setting up its IN and OUT parameters, and
00587 methods for executing the call to a stored procedure.
00588
00589 <P><B>Note:</B> This method is optimized for handling stored
00590 procedure call statements. Some drivers may send the call
00591 statement to the database when the method <code>prepareCall</code>
00592 is done; others
00593 may wait until the <code>CallableStatement</code> object
00594 is executed. This has no
00595 direct effect on users; however, it does affect which method
00596 throws certain SQLExceptions.
00597
00598 Result sets created using the returned CallableStatement will have
00599 forward-only type and read-only concurrency, by default.
00600
00601 @param sql a SQL statement that may contain one or more '?'
00602 parameter placeholders. Typically this statement is a JDBC
00603 function call escape string.
00604 @return a new CallableStatement object containing the
00605 pre-compiled SQL statement
00606 }
00607
00608 function TZAbstractConnection.PrepareCall(
00609 const SQL: string): IZCallableStatement;
00610 begin
00611 Result := CreateCallableStatement(SQL, nil);
00612 end;
00613
00614 {**
00615 Creates a <code>CallableStatement</code> object for calling
00616 database stored procedures.
00617 The <code>CallableStatement</code> object provides
00618 methods for setting up its IN and OUT parameters, and
00619 methods for executing the call to a stored procedure.
00620
00621 @param SQL a SQL statement that may contain one or more '?'
00622 parameter placeholders. Typically this statement is a JDBC
00623 function call escape string.
00624 @param Info a statement parameters.
00625 @return a new CallableStatement object containing the
00626 pre-compiled SQL statement
00627 }
00628 function TZAbstractConnection.PrepareCallWithParams(const SQL: string;
00629 Info: TStrings): IZCallableStatement;
00630 begin
00631 Result := CreateCallableStatement(SQL, Info);
00632 end;
00633
00634 {**
00635 Creates a callable statement object.
00636 @param SQL a SQL query string.
00637 @param Info a statement parameters.
00638 @returns a created statement.
00639 }
00640 function TZAbstractConnection.CreateCallableStatement(const SQL: string;
00641 Info: TStrings): IZCallableStatement;
00642 begin
00643 Result := nil;
00644 RaiseUnsupportedException;
00645 end;
00646
00647 {**
00648 Creates an object to send/recieve notifications from SQL server.
00649 @param Event an event name.
00650 @returns a created notification object.
00651 }
00652 function TZAbstractConnection.CreateNotification(const Event: string): IZNotification;
00653 begin
00654 Result := nil;
00655 RaiseUnsupportedException;
00656 end;
00657
00658 {**
00659 Creates a sequence generator object.
00660 @param Sequence a name of the sequence generator.
00661 @param BlockSize a number of unique keys requested in one trip to SQL server.
00662 @returns a created sequence object.
00663 }
00664 function TZAbstractConnection.CreateSequence(const Sequence: string;
00665 BlockSize: Integer): IZSequence;
00666 begin
00667 Result := nil;
00668 RaiseUnsupportedException;
00669 end;
00670
00671 {**
00672 Converts the given SQL statement into the system's native SQL grammar.
00673 A driver may convert the JDBC sql grammar into its system's
00674 native SQL grammar prior to sending it; this method returns the
00675 native form of the statement that the driver would have sent.
00676
00677 @param sql a SQL statement that may contain one or more '?'
00678 parameter placeholders
00679 @return the native form of this statement
00680 }
00681 function TZAbstractConnection.NativeSQL(const SQL: string): string;
00682 begin
00683 Result := SQL;
00684 end;
00685
00686 {**
00687 Sets this connection's auto-commit mode.
00688 If a connection is in auto-commit mode, then all its SQL
00689 statements will be executed and committed as individual
00690 transactions. Otherwise, its SQL statements are grouped into
00691 transactions that are terminated by a call to either
00692 the method <code>commit</code> or the method <code>rollback</code>.
00693 By default, new connections are in auto-commit mode.
00694
00695 The commit occurs when the statement completes or the next
00696 execute occurs, whichever comes first. In the case of
00697 statements returning a ResultSet, the statement completes when
00698 the last row of the ResultSet has been retrieved or the
00699 ResultSet has been closed. In advanced cases, a single
00700 statement may return multiple results as well as output
00701 parameter values. In these cases the commit occurs when all results and
00702 output parameter values have been retrieved.
00703
00704 @param autoCommit true enables auto-commit; false disables auto-commit.
00705 }
00706 procedure TZAbstractConnection.SetAutoCommit(AutoCommit: Boolean);
00707 begin
00708 FAutoCommit := AutoCommit;
00709 end;
00710
00711 {**
00712 Gets the current auto-commit state.
00713 @return the current state of auto-commit mode
00714 @see #setAutoCommit
00715 }
00716 function TZAbstractConnection.GetAutoCommit: Boolean;
00717 begin
00718 Result := FAutoCommit;
00719 end;
00720
00721 {**
00722 Makes all changes made since the previous
00723 commit/rollback permanent and releases any database locks
00724 currently held by the Connection. This method should be
00725 used only when auto-commit mode has been disabled.
00726 @see #setAutoCommit
00727 }
00728 procedure TZAbstractConnection.Commit;
00729 begin
00730 RaiseUnsupportedException;
00731 end;
00732
00733 procedure TZAbstractConnection.CommitPrepared(const transactionid: string);
00734 begin
00735 RaiseUnsupportedException;
00736 end;
00737
00738 {**
00739 Drops all changes made since the previous
00740 commit/rollback and releases any database locks currently held
00741 by this Connection. This method should be used only when auto-
00742 commit has been disabled.
00743 @see #setAutoCommit
00744 }
00745 procedure TZAbstractConnection.Rollback;
00746 begin
00747 RaiseUnsupportedException;
00748 end;
00749
00750 procedure TZAbstractConnection.RollbackPrepared(const transactionid: string);
00751 begin
00752 RaiseUnsupportedException;
00753 end;
00754
00755 {**
00756 Ping Current Connection's server, if client was disconnected,
00757 the connection is resumed.
00758 @return 0 if succesfull or error code if any error occurs
00759 }
00760 function TZAbstractConnection.PingServer: Integer;
00761 begin
00762 Result := 1;
00763 RaiseUnsupportedException;
00764 end;
00765
00766 {**
00767 Escape a string so it's acceptable for the Connection's server.
00768 @param value string that should be escaped
00769 @return Escaped string
00770 }
00771 function TZAbstractConnection.EscapeString(Value : String) : String;
00772 begin
00773 Result := EncodeCString(Value);
00774 end;
00775
00776 {**
00777 Releases a Connection's database and JDBC resources
00778 immediately instead of waiting for
00779 them to be automatically released.
00780
00781 <P><B>Note:</B> A Connection is automatically closed when it is
00782 garbage collected. Certain fatal errors also result in a closed
00783 Connection.
00784 }
00785
00786 procedure TZAbstractConnection.Close;
00787 begin
00788 FClosed := True;
00789 end;
00790
00791 {**
00792 Tests to see if a Connection is closed.
00793 @return true if the connection is closed; false if it's still open
00794 }
00795 function TZAbstractConnection.IsClosed: Boolean;
00796 begin
00797 Result := FClosed;
00798 end;
00799
00800 {**
00801 Gets the parent ZDBC driver.
00802 @returns the parent ZDBC driver interface.
00803 }
00804 function TZAbstractConnection.GetDriver: IZDriver;
00805 begin
00806 Result := FDriver;
00807 end;
00808
00809 {**
00810 Gets the metadata regarding this connection's database.
00811 A Connection's database is able to provide information
00812 describing its tables, its supported SQL grammar, its stored
00813 procedures, the capabilities of this connection, and so on. This
00814 information is made available through a DatabaseMetaData
00815 object.
00816
00817 @return a DatabaseMetaData object for this Connection
00818 }
00819 function TZAbstractConnection.GetMetadata: IZDatabaseMetadata;
00820 begin
00821 Result := FMetadata as IZDatabaseMetadata;
00822 end;
00823
00824 {**
00825 Gets a connection parameters.
00826 @returns a list with connection parameters.
00827 }
00828 function TZAbstractConnection.GetParameters: TStrings;
00829 begin
00830 Result := Info;
00831 end;
00832
00833 {**
00834 Gets the client's full version number. Initially this should be 0.
00835 The format of the version resturned must be XYYYZZZ where
00836 X = Major version
00837 YYY = Minor version
00838 ZZZ = Sub version
00839 @return this clients's full version number
00840 }
00841 function TZAbstractConnection.GetClientVersion: Integer;
00842 begin
00843 Result := 0;
00844 end;
00845
00846 {**
00847 Gets the host's full version number. Initially this should be 0.
00848 The format of the version returned must be XYYYZZZ where
00849 X = Major version
00850 YYY = Minor version
00851 ZZZ = Sub version
00852 @return this server's full version number
00853 }
00854 function TZAbstractConnection.GetHostVersion: Integer;
00855 begin
00856 Result := 0;
00857 end;
00858 {END ADDED by fduenas 15-06-2006}
00859
00860 {**
00861 Puts this connection in read-only mode as a hint to enable
00862 database optimizations.
00863
00864 <P><B>Note:</B> This method cannot be called while in the
00865 middle of a transaction.
00866
00867 @param readOnly true enables read-only mode; false disables
00868 read-only mode.
00869 }
00870 procedure TZAbstractConnection.SetReadOnly(ReadOnly: Boolean);
00871 begin
00872 FReadOnly := ReadOnly;
00873 end;
00874
00875 {**
00876 Tests to see if the connection is in read-only mode.
00877 @return true if connection is read-only and false otherwise
00878 }
00879 function TZAbstractConnection.IsReadOnly: Boolean;
00880 begin
00881 Result := FReadOnly;
00882 end;
00883
00884 {**
00885 Sets a catalog name in order to select
00886 a subspace of this Connection's database in which to work.
00887 If the driver does not support catalogs, it will
00888 silently ignore this request.
00889 }
00890 procedure TZAbstractConnection.SetCatalog(const Catalog: string);
00891 begin
00892 end;
00893
00894 {**
00895 Returns the Connection's current catalog name.
00896 @return the current catalog name or null
00897 }
00898 function TZAbstractConnection.GetCatalog: string;
00899 begin
00900 Result := '';
00901 end;
00902
00903 {**
00904 Attempts to change the transaction isolation level to the one given.
00905 The constants defined in the interface <code>Connection</code>
00906 are the possible transaction isolation levels.
00907
00908 <P><B>Note:</B> This method cannot be called while
00909 in the middle of a transaction.
00910
00911 @param level one of the TRANSACTION_* isolation values with the
00912 exception of TRANSACTION_NONE; some databases may not support other values
00913 @see DatabaseMetaData#supportsTransactionIsolationLevel
00914 }
00915 procedure TZAbstractConnection.SetTransactionIsolation(
00916 Level: TZTransactIsolationLevel);
00917 begin
00918 FTransactIsolationLevel := Level;
00919 end;
00920
00921 {**
00922 Gets this Connection's current transaction isolation level.
00923 @return the current TRANSACTION_* mode value
00924 }
00925 function TZAbstractConnection.GetTransactionIsolation: TZTransactIsolationLevel;
00926 begin
00927 Result := FTransactIsolationLevel;
00928 end;
00929
00930 {**
00931 Returns the first warning reported by calls on this Connection.
00932 <P><B>Note:</B> Subsequent warnings will be chained to this
00933 SQLWarning.
00934 @return the first SQLWarning or null
00935 }
00936 function TZAbstractConnection.GetWarnings: EZSQLWarning;
00937 begin
00938 Result := nil;
00939 end;
00940
00941 {**
00942 Clears all warnings reported for this <code>Connection</code> object.
00943 After a call to this method, the method <code>getWarnings</code>
00944 returns null until a new warning is reported for this Connection.
00945 }
00946 procedure TZAbstractConnection.ClearWarnings;
00947 begin
00948 end;
00949
00950 { TZAbstractNotification }
00951
00952 {**
00953 Creates this object and assignes the main properties.
00954 @param Connection a database connection object.
00955 @param EventName a name of the SQL event.
00956 }
00957 constructor TZAbstractNotification.Create(Connection: IZConnection;
00958 EventName: string);
00959 begin
00960 FConnection := Connection;
00961 FEventName := EventName;
00962 end;
00963
00964 {**
00965 Gets an event name.
00966 @return an event name for this notification.
00967 }
00968 function TZAbstractNotification.GetEvent: string;
00969 begin
00970 Result := FEventName;
00971 end;
00972
00973 {**
00974 Sets a listener to the specified event.
00975 }
00976 procedure TZAbstractNotification.Listen;
00977 begin
00978 end;
00979
00980 {**
00981 Removes a listener to the specified event.
00982 }
00983 procedure TZAbstractNotification.Unlisten;
00984 begin
00985 end;
00986
00987 {**
00988 Checks for any pending events.
00989 @return a string with incoming events??
00990 }
00991 function TZAbstractNotification.CheckEvents: string;
00992 begin
00993 Result := '';
00994 end;
00995
00996 {**
00997 Sends a notification string.
00998 }
00999 procedure TZAbstractNotification.DoNotify;
01000 begin
01001 end;
01002
01003 {**
01004 Returns the <code>Connection</code> object
01005 that produced this <code>Statement</code> object.
01006 @return the connection that produced this statement
01007 }
01008 function TZAbstractNotification.GetConnection: IZConnection;
01009 begin
01010 Result := FConnection;
01011 end;
01012
01013 { TZAbstractSequence }
01014
01015 {**
01016 Creates this sequence object.
01017 @param Connection an SQL connection interface.
01018 @param Name a name of the sequence generator.
01019 @param BlockSize a number of unique keys requested in one trip to server.
01020 }
01021 constructor TZAbstractSequence.Create(Connection: IZConnection;
01022 Name: string; BlockSize: Integer);
01023 begin
01024 FConnection := Connection;
01025 FName := Name;
01026 FBlockSize := BlockSize;
01027 end;
01028
01029 {**
01030 Returns the <code>Connection</code> object
01031 that produced this <code>Statement</code> object.
01032 @return the connection that produced this statement
01033 }
01034 function TZAbstractSequence.GetConnection: IZConnection;
01035 begin
01036 Result := FConnection;
01037 end;
01038
01039 {**
01040 Returns a name of the sequence generator.
01041 @return a name of this sequence generator.
01042 }
01043 function TZAbstractSequence.GetName: string;
01044 begin
01045 Result := FName;
01046 end;
01047
01048 {**
01049 Returns the assigned block size for this sequence.
01050 @return the assigned block size.
01051 }
01052 function TZAbstractSequence.GetBlockSize: Integer;
01053 begin
01054 Result := FBlockSize;
01055 end;
01056
01057 {**
01058 Gets the current unique key generated by this sequence.
01059 @param the last generated unique key.
01060 }
01061 function TZAbstractSequence.GetCurrentValue: Int64;
01062 begin
01063 Result := 0;
01064 end;
01065
01066 {
01067 function TZAbstractSequence.GetCurrentValueSQL: String;
01068 begin
01069 result:='IMPLEMENT';
01070 end;
01071 }
01072
01073 {**
01074 Gets the next unique key generated by this sequence.
01075 @param the next generated unique key.
01076 }
01077 function TZAbstractSequence.GetNextValue: Int64;
01078 begin
01079 Result := 0;
01080 end;
01081
01082 {
01083 function TZAbstractSequence.GetNextValueSQL: String;
01084 begin
01085 result:='IMPLEMENT';
01086 end;
01087 }
01088
01089 {**
01090 Sets the block size for this sequence.
01091 @param Value the block size.
01092 }
01093 procedure TZAbstractSequence.SetBlockSize(const Value: Integer);
01094 begin
01095 FBlockSize := Value;
01096 end;
01097
01098 {**
01099 Sets a name of the sequence generator.
01100 @param Value a name of this sequence generator.
01101 }
01102 procedure TZAbstractSequence.SetName(const Value: string);
01103 begin
01104 FName := Value;
01105 end;
01106
01107 end.