zeoslib  UNKNOWN
 All Files
ZDbcConnection.pas
Go to the documentation of this file.
1 {*********************************************************}
2 { }
3 { Zeos Database Objects }
4 { Abstract Database Connectivity Classes }
5 { }
6 { Originally written by Sergey Seroukhov }
7 { }
8 {*********************************************************}
9 
10 {@********************************************************}
11 { Copyright (c) 1999-2012 Zeos Development Group }
12 { }
13 { License Agreement: }
14 { }
15 { This library is distributed in the hope that it will be }
16 { useful, but WITHOUT ANY WARRANTY; without even the }
17 { implied warranty of MERCHANTABILITY or FITNESS FOR }
18 { A PARTICULAR PURPOSE. See the GNU Lesser General }
19 { Public License for more details. }
20 { }
21 { The source code of the ZEOS Libraries and packages are }
22 { distributed under the Library GNU General Public }
23 { License (see the file COPYING / COPYING.ZEOS) }
24 { with the following modification: }
25 { As a special exception, the copyright holders of this }
26 { library give you permission to link this library with }
27 { independent modules to produce an executable, }
28 { regardless of the license terms of these independent }
29 { modules, and to copy and distribute the resulting }
30 { executable under terms of your choice, provided that }
31 { you also meet, for each linked independent module, }
32 { the terms and conditions of the license of that module. }
33 { An independent module is a module which is not derived }
34 { from or based on this library. If you modify this }
35 { library, you may extend this exception to your version }
36 { of the library, but you are not obligated to do so. }
37 { If you do not wish to do so, delete this exception }
38 { statement from your version. }
39 { }
40 { }
41 { The project web site is located on: }
42 { http://zeos.firmos.at (FORUM) }
43 { http://sourceforge.net/p/zeoslib/tickets/ (BUGTRACKER)}
44 { svn://svn.code.sf.net/p/zeoslib/code-0/trunk (SVN) }
45 { }
46 { http://www.sourceforge.net/projects/zeoslib. }
47 { }
48 { }
49 { Zeos Development Group. }
50 {********************************************************@}
51 
52 unit ZDbcConnection;
53 
54 interface
55 
56 {$I ZDbc.inc}
57 
58 uses
59 {$IFDEF FPC}
60  {$IFDEF WIN32}
61  Comobj,
62  {$ENDIF}
63 {$ENDIF}
64 {$IFDEF WITH_LCONVENCODING}
65  LConvEncoding,
66 {$ENDIF}
67  Types, Classes, {$IFDEF MSEgui}mclasses,{$ENDIF} SysUtils,
68  ZClasses, ZDbcIntfs, ZTokenizer, ZCompatibility, ZGenericSqlToken,
69  ZGenericSqlAnalyser, ZPlainDriver, ZURL, ZCollections, ZVariant;
70 
71 type
72 
73  {** Implements Abstract Database Driver. }
74  {$WARNINGS OFF} //to supress the deprecated Warning of connect
75  TZAbstractDriver = class(TInterfacedObject, IZDriver)
76  protected
77  FCachedPlainDrivers: IZHashMap;
78  FSupportedProtocols: TStringDynArray;
79  procedure AddSupportedProtocol(AProtocol: String);
80  function AddPlainDriverToCache(PlainDriver: IZPlainDriver; const Protocol: string = ''; LibLocation: string = ''): String;
81  function GetPlainDriverFromCache(const Protocol, LibLocation: string): IZPlainDriver;
82  function GetPlainDriver(const Url: TZURL; const InitDriver: Boolean = True): IZPlainDriver; virtual;
83  public
84  constructor Create; virtual;
85  destructor Destroy; override;
86 
87  function GetSupportedProtocols: TStringDynArray;
88  function GetSupportedClientCodePages(const Url: TZURL;
89  Const {$IFNDEF UNICODE}AutoEncode, {$ENDIF} SupportedsOnly: Boolean;
90  CtrlsCPType: TZControlsCodePage = cCP_UTF16): TStringDynArray;
91  function Connect(const Url: string; Info: TStrings = nil): IZConnection; overload; deprecated;
92  function Connect(const Url: TZURL): IZConnection; overload; virtual;
93  function AcceptsURL(const Url: string): Boolean; virtual;
94 
95  function GetPropertyInfo(const Url: string; Info: TStrings): TStrings; virtual;
96  function GetMajorVersion: Integer; virtual;
97  function GetMinorVersion: Integer; virtual;
98  function GetSubVersion: Integer; virtual;
99  function GetTokenizer: IZTokenizer; virtual;
100  function GetStatementAnalyser: IZStatementAnalyser; virtual;
101  function GetClientVersion(const Url: string): Integer; virtual;
102  end;
103  {$WARNINGS OFF}
104 
105  {** Implements Abstract Database Connection. }
106 
107  { TZAbstractConnection }
108 
109  TZAbstractConnection = class(TZCodePagedObject, IZConnection)
110  private
111  FDriver: IZDriver;
112  FIZPlainDriver: IZPlainDriver;
113  FAutoCommit: Boolean;
114  FReadOnly: Boolean;
115  FTransactIsolationLevel: TZTransactIsolationLevel;
116  FClosed: Boolean;
117  FURL: TZURL;
118  FUseMetadata: Boolean;
119  function GetHostName: string;
120  procedure SetHostName(const Value: String);
121  function GetPort: Integer;
122  procedure SetConnPort(const Value: Integer);
123  function GetDatabase: string;
124  procedure SetDatabase(const Value: String);
125  function GetUser: string;
126  procedure SetUser(const Value: String);
127  function GetPassword: string;
128  procedure SetPassword(const Value: String);
129  function GetInfo: TStrings;
130  protected
131  FDisposeCodePage: Boolean;
132  FUndefinedVarcharAsStringLength: Integer; //used for PostgreSQL and SQLite
133  FClientCodePage: String;
134  FMetadata: TContainedObject;
135  {$IFDEF ZEOS_TEST_ONLY}
136  FTestMode: Byte;
137  {$ENDIF}
138  procedure InternalCreate; virtual; abstract;
139  function GetEncoding: TZCharEncoding;
140  function GetConSettings: PZConSettings;
141  procedure CheckCharEncoding(const CharSet: String; const DoArrange: Boolean = False);
142  function GetClientCodePageInformations: PZCodePage; //EgonHugeist
143  function GetAutoEncodeStrings: Boolean; //EgonHugeist
144  procedure SetAutoEncodeStrings(const Value: Boolean);
145  procedure OnPropertiesChange(Sender: TObject); virtual;
146  procedure RaiseUnsupportedException;
147 
148  function CreateRegularStatement(Info: TStrings): IZStatement;
149  virtual;
150  function CreatePreparedStatement(const SQL: string; Info: TStrings):
151  IZPreparedStatement; virtual;
152  function CreateCallableStatement(const SQL: string; Info: TStrings):
153  IZCallableStatement; virtual;
154 
155  property Driver: IZDriver read FDriver write FDriver;
156  property PlainDriver: IZPlainDriver read FIZPlainDriver write FIZPlainDriver;
157  property HostName: string read GetHostName write SetHostName;
158  property Port: Integer read GetPort write SetConnPort;
159  property Database: string read GetDatabase write SetDatabase;
160  property User: string read GetUser write SetUser;
161  property Password: string read GetPassword write SetPassword;
162  property Info: TStrings read GetInfo;
163  property AutoCommit: Boolean read FAutoCommit write FAutoCommit;
164  property ReadOnly: Boolean read FReadOnly write FReadOnly;
165  property URL: TZURL read FURL;
166  property TransactIsolationLevel: TZTransactIsolationLevel
167  read FTransactIsolationLevel write FTransactIsolationLevel;
168  property Closed: Boolean read FClosed write FClosed;
169  public
170  constructor Create(Driver: IZDriver; const Url: string;
171  PlainDriver: IZPlainDriver; const HostName: string; Port: Integer;
172  const Database: string; const User: string; const Password: string;
173  Info: TStrings); overload; deprecated;
174  constructor Create(const ZUrl: TZURL); overload;
175  destructor Destroy; override;
176 
177  function CreateStatement: IZStatement;
178  function PrepareStatement(const SQL: string): IZPreparedStatement;
179  function PrepareCall(const SQL: string): IZCallableStatement;
180 
181  function CreateStatementWithParams(Info: TStrings): IZStatement;
182  function PrepareStatementWithParams(const SQL: string; Info: TStrings):
183  IZPreparedStatement;
184  function PrepareCallWithParams(const SQL: string; Info: TStrings):
185  IZCallableStatement;
186 
187  function CreateNotification(const Event: string): IZNotification; virtual;
188  function CreateSequence(const Sequence: string; BlockSize: Integer):
189  IZSequence; virtual;
190 
191  function NativeSQL(const SQL: string): string; virtual;
192 
193  procedure SetAutoCommit(Value: Boolean); virtual;
194  function GetAutoCommit: Boolean; virtual;
195 
196  procedure Commit; virtual;
197  procedure Rollback; virtual;
198 
199  //2Phase Commit Support initially for PostgresSQL (firmos) 21022006
200  procedure PrepareTransaction(const transactionid: string);virtual;
201  procedure CommitPrepared(const transactionid: string);virtual;
202  procedure RollbackPrepared(const transactionid: string);virtual;
203 
204  //Ping Support initially for MySQL 27032006 (firmos)
205  function PingServer: Integer; virtual;
206  function EscapeString(Value: RawByteString): RawByteString; virtual;
207 
208  procedure Open; virtual;
209  procedure Close; virtual;
210  function IsClosed: Boolean; virtual;
211 
212  function GetDriver: IZDriver;
213  function GetIZPlainDriver: IZPlainDriver;
214  function GetMetadata: IZDatabaseMetadata;
215  function GetParameters: TStrings;
216  {ADDED by fduenas 15-06-2006}
217  function GetClientVersion: Integer; virtual;
218  function GetHostVersion: Integer; virtual;
219  {END ADDED by fduenas 15-06-2006}
220  function GetDescription: AnsiString;
221  procedure SetReadOnly(ReadOnly: Boolean); virtual;
222  function IsReadOnly: Boolean; virtual;
223 
224  procedure SetCatalog(const Catalog: string); virtual;
225  function GetCatalog: string; virtual;
226 
227  procedure SetTransactionIsolation(Level: TZTransactIsolationLevel); virtual;
228  function GetTransactionIsolation: TZTransactIsolationLevel; virtual;
229 
230  function GetWarnings: EZSQLWarning; virtual;
231  procedure ClearWarnings; virtual;
232  function GetBinaryEscapeString(const Value: RawByteString): String; overload; virtual;
233  function GetBinaryEscapeString(const Value: TByteDynArray): String; overload; virtual;
234  function GetEscapeString(const Value: ZWideString): ZWideString; overload; virtual;
235  function GetEscapeString(const Value: RawByteString): RawByteString; overload; virtual;
236  function UseMetadata: boolean;
237  procedure SetUseMetadata(Value: Boolean);
238  {$IFDEF ZEOS_TEST_ONLY}
239  function GetTestMode : Byte;
240  procedure SetTestMode(Mode: Byte);
241  {$ENDIF}
242 end;
243 
244  {** Implements Abstract Database notification. }
245  TZAbstractNotification = class(TInterfacedObject, IZNotification)
246  private
247  FEventName: string;
248  FConnection: IZConnection;
249  protected
250  property EventName: string read FEventName write FEventName;
251  property Connection: IZConnection read FConnection write FConnection;
252  public
253  constructor Create(Connection: IZConnection; EventName: string);
254  function GetEvent: string;
255  procedure Listen; virtual;
256  procedure Unlisten; virtual;
257  procedure DoNotify; virtual;
258  function CheckEvents: string; virtual;
259 
260  function GetConnection: IZConnection; virtual;
261  end;
262 
263  {** Implements Abstract Sequence generator. }
264  TZAbstractSequence = class(TInterfacedObject, IZSequence)
265  private
266  FName: string;
267  FBlockSize: Integer;
268  FConnection: IZConnection;
269  protected
270  function GetName: string; virtual;
271  function GetBlockSize: Integer; virtual;
272  procedure SetName(const Value: string); virtual;
273  procedure SetBlockSize(const Value: Integer); virtual;
274  property Connection: IZConnection read FConnection write FConnection;
275  public
276  constructor Create(Connection: IZConnection; Name: string;
277  BlockSize: Integer);
278 
279  function GetCurrentValue: Int64; virtual;
280  function GetNextValue: Int64; virtual;
281 
282  function GetCurrentValueSQL: string; virtual; abstract;
283  function GetNextValueSQL: string; virtual; abstract;
284 
285  function GetConnection: IZConnection; virtual;
286 
287  property Name: string read GetName write SetName;
288  property BlockSize: Integer read GetBlockSize write SetBlockSize;
289  end;
290 
291 implementation
292 
293 uses ZMessages, ZSysUtils, ZDbcMetadata, ZDbcUtils, ZEncoding
294  {$IFDEF WITH_UNITANSISTRINGS},AnsiStrings{$ENDIF};
295 
296 { TZAbstractDriver }
297 
298 {**
299  Constructs this object with default properties.
300 }
301 constructor TZAbstractDriver.Create;
302 begin
303  FCachedPlainDrivers := TZHashMap.Create;
304 end;
305 
306 {**
307  Destroys this object and cleanups the memory.
308 }
309 destructor TZAbstractDriver.Destroy;
310 begin
311  FCachedPlainDrivers.Clear;
312  FCachedPlainDrivers := nil;
313  inherited Destroy;
314 end;
315 
316 function TZAbstractDriver.GetSupportedProtocols: TStringDynArray;
317 begin
318  Result := FSupportedProtocols;
319 end;
320 
321 {**
322  EgonHugeist:
323  Get names of the supported CharacterSets.
324  For example: ASCII, UTF8...
325 }
326 function TZAbstractDriver.GetSupportedClientCodePages(const Url: TZURL;
327  Const {$IFNDEF UNICODE}AutoEncode,{$ENDIF} SupportedsOnly: Boolean;
328  CtrlsCPType: TZControlsCodePage = cCP_UTF16): TStringDynArray;
329 var
330  Plain: IZPlainDriver;
331 begin
332  Plain := GetPlainDriverFromCache(Url.Protocol, '');
333  if Assigned(Plain) then
334  Result := Plain.GetSupportedClientCodePages({$IFNDEF UNICODE}AutoEncode,{$ENDIF}
335  not SupportedsOnly, CtrlsCPType);
336 end;
337 
338 {**
339  Attempts to make a database connection to the given URL.
340  The driver should return "null" if it realizes it is the wrong kind
341  of driver to connect to the given URL. This will be common, as when
342  the JDBC driver manager is asked to connect to a given URL it passes
343  the URL to each loaded driver in turn.
344 
345  <P>The driver should raise a SQLException if it is the right
346  driver to connect to the given URL, but has trouble connecting to
347  the database.
348 
349  <P>The java.util.Properties argument can be used to passed arbitrary
350  string tag/value pairs as connection arguments.
351  Normally at least "user" and "password" properties should be
352  included in the Properties.
353 
354  @param url the URL of the database to which to connect
355  @param info a list of arbitrary string tag/value pairs as
356  connection arguments. Normally at least a "user" and
357  "password" property should be included.
358  @return a <code>Connection</code> object that represents a
359  connection to the URL
360 }
361 {$WARNINGS OFF}
362 function TZAbstractDriver.Connect(const Url: string; Info: TStrings): IZConnection;
363 var
364  TempURL: TZURL;
365 begin
366  TempURL := TZURL.Create(Url, Info);
367  try
368  Result := Connect(TempURL);
369  finally
370  TempUrl.Free;
371  end;
372 end;
373 
374 function TZAbstractDriver.Connect(const Url: TZURL): IZConnection;
375 begin
376  Result := nil;
377 end;
378 {$WARNINGS ON}
379 
380 {**
381  Returns true if the driver thinks that it can open a connection
382  to the given URL. Typically drivers will return true if they
383  understand the subprotocol specified in the URL and false if
384  they don't.
385  @param url the URL of the database
386  @return true if this driver can connect to the given URL
387 }
388 function TZAbstractDriver.AcceptsURL(const Url: string): Boolean;
389 var
390  I: Integer;
391  Protocols: TStringDynArray;
392 begin
393  Result := False;
394  Protocols := GetSupportedProtocols;
395  for I := Low(Protocols) to High(Protocols) do
396  begin
397  Result := StartsWith(LowerCase(Url), Format('zdbc:%s:', [LowerCase(Protocols[I])]));
398  if Result then
399  Break;
400  end;
401 end;
402 
403 procedure TZAbstractDriver.AddSupportedProtocol(AProtocol: String);
404 begin
405  SetLength(FSupportedProtocols, Length(FSupportedProtocols)+1);
406  FSupportedProtocols[High(FSupportedProtocols)] := AProtocol;
407 end;
408 
409 function TZAbstractDriver.AddPlainDriverToCache(PlainDriver: IZPlainDriver;
410  const Protocol: string = ''; LibLocation: string = ''): String;
411 var
412  TempKey: IZAnyValue;
413 begin
414  if Protocol = '' then
415  begin
416  Result := PlainDriver.GetProtocol;
417  TempKey := TZAnyValue.CreateWithString(PlainDriver.GetProtocol)
418  end
419  else
420  begin
421  Result := Protocol;
422  TempKey := TZAnyValue.CreateWithString(Protocol+LibLocation);
423  end;
424  FCachedPlainDrivers.Put(TempKey, PlainDriver);
425 end;
426 
427 function TZAbstractDriver.GetPlainDriverFromCache(const Protocol, LibLocation: string): IZPlainDriver;
428 var
429  TempKey: IZAnyValue;
430  TempPlain: IZPlainDriver;
431 begin
432  TempKey := TZAnyValue.CreateWithString(Protocol+LibLocation);
433  Result := FCachedPlainDrivers.Get(TempKey) as IZPlainDriver;
434  if Result = nil then
435  begin
436  TempKey := nil;
437  TempKey := TZAnyValue.CreateWithString(Protocol);
438  TempPlain := FCachedPlainDrivers.Get(TempKey) as IZPlainDriver;
439  if Assigned(TempPlain) then
440  Result := TempPlain.Clone;
441  end;
442 end;
443 
444 {**
445  Gets plain driver for selected protocol.
446  @param Url a database connection URL.
447  @return a selected plaindriver.
448 }
449 function TZAbstractDriver.GetPlainDriver(const Url: TZURL;
450  const InitDriver: Boolean): IZPlainDriver;
451 begin
452  Result := GetPlainDriverFromCache(Url.Protocol, Url.LibLocation);
453  if Assigned(Result) and InitDriver then
454  Result.Initialize(Url.LibLocation);
455 end;
456 
457 {**
458  Gets information about the possible properties for this driver.
459  <p>The getPropertyInfo method is intended to allow a generic GUI tool to
460  discover what properties it should prompt a human for in order to get
461  enough information to connect to a database. Note that depending on
462  the values the human has supplied so far, additional values may become
463  necessary, so it may be necessary to iterate though several calls
464  to getPropertyInfo.
465 
466  @param url the URL of the database to which to connect
467  @param info a proposed list of tag/value pairs that will be sent on
468  connect open
469  @return an array of DriverPropertyInfo objects describing possible
470  properties. This array may be an empty array if no properties
471  are required.
472 }
473 function TZAbstractDriver.GetPropertyInfo(const Url: string; Info: TStrings): TStrings;
474 begin
475  Result := nil;
476 end;
477 
478 {**
479  Gets the driver's major version number. Initially this should be 1.
480  @return this driver's major version number
481 }
482 function TZAbstractDriver.GetMajorVersion: Integer;
483 begin
484  Result := 1;
485 end;
486 
487 {**
488  Gets the driver's minor version number. Initially this should be 0.
489  @return this driver's minor version number
490 }
491 function TZAbstractDriver.GetMinorVersion: Integer;
492 begin
493  Result := 0;
494 end;
495 
496 {**
497  Gets the driver's sub version (revision) number. Initially this should be 0.
498  @return this driver's sub version number
499 }
500 function TZAbstractDriver.GetSubVersion: Integer;
501 begin
502  Result := 0;
503 end;
504 {**
505  Creates a generic statement analyser object.
506  @returns a generic statement analyser object.
507 }
508 function TZAbstractDriver.GetStatementAnalyser: IZStatementAnalyser;
509 begin
510  Result := TZGenericStatementAnalyser.Create; { thread save! Allways return a new Analyser! }
511 end;
512 
513 {**
514  Creates a generic tokenizer object.
515  @returns a created generic tokenizer object.
516 }
517 function TZAbstractDriver.GetTokenizer: IZTokenizer;
518 begin
519  Result := TZGenericSQLTokenizer.Create;
520 end;
521 
522 {**
523  Returns the version of the plain driver library that will be used to open a connection
524  to the given URL.
525  @param url the URL of the database
526  @return the version number of the plain driver library for the give URL
527 }
528 function TZAbstractDriver.GetClientVersion(const Url: string): Integer;
529 begin
530  Result := 0;
531 end;
532 
533 { TZAbstractConnection }
534 
535 function TZAbstractConnection.GetHostName: string;
536 begin
537  Result := FURL.HostName;
538 end;
539 
540 procedure TZAbstractConnection.SetHostName(const Value: String);
541 begin
542  FURL.HostName := Value;
543 end;
544 
545 function TZAbstractConnection.GetPort: Integer;
546 begin
547  Result := FURL.Port;
548 end;
549 
550 procedure TZAbstractConnection.SetConnPort(const Value: Integer);
551 begin
552  FURL.Port := Value;
553 end;
554 
555 function TZAbstractConnection.GetDatabase: string;
556 begin
557  Result := FURL.Database;
558 end;
559 
560 procedure TZAbstractConnection.SetDatabase(const Value: String);
561 begin
562  FURL.Database := Value;
563 end;
564 
565 function TZAbstractConnection.GetUser: string;
566 begin
567  Result := FURL.UserName;
568 end;
569 
570 procedure TZAbstractConnection.SetUser(const Value: String);
571 begin
572  FURL.UserName := Value;
573 end;
574 
575 function TZAbstractConnection.GetPassword: string;
576 begin
577  Result := FURL.Password;
578 end;
579 
580 procedure TZAbstractConnection.SetPassword(const Value: String);
581 begin
582  FURL.Password := Value;
583 end;
584 
585 function TZAbstractConnection.GetInfo: TStrings;
586 begin
587  Result := FURL.Properties;
588 end;
589 
590 function TZAbstractConnection.GetEncoding: TZCharEncoding;
591 begin
592  Result := ConSettings.ClientCodePage^.Encoding;
593 end;
594 
595 function TZAbstractConnection.GetConSettings: PZConSettings;
596 begin
597  Result := ConSettings;
598 end;
599 
600 {**
601  EgonHugeist: Check if the given Charset for Compiler/Database-Support!!
602  Not supported means if there is a pissible String-DataLoss.
603  So it raises an Exception if case of settings. This handling
604  is an improofment to inform Zeos-Users about the troubles the given
605  CharacterSet may have.
606  @param CharSet the CharacterSet which has to be proofed
607  @param DoArrange represents a switch to check and set a aternative ZAlias as
608  default. This means it ignores the choosen Client-CharacterSet and sets a
609  "more" Zeos-Compatible Client-CharacterSet if known.
610 }
611 procedure TZAbstractConnection.CheckCharEncoding(const CharSet: String;
612  const DoArrange: Boolean = False);
613 begin
614  ConSettings.ClientCodePage := GetIZPlainDriver.ValidateCharEncoding(CharSet, DoArrange);
615  FClientCodePage := ConSettings.ClientCodePage^.Name; //resets the developer choosen ClientCodePage
616  {$IFDEF WITH_LCONVENCODING}
617  SetConvertFunctions(ConSettings.CTRL_CP, ConSettings.ClientCodePage.CP,
618  ConSettings.PlainConvertFunc, ConSettings.DbcConvertFunc);
619  {$ENDIF}
620  ZEncoding.SetConvertFunctions(ConSettings);
621 end;
622 
623 
624 {**
625  EgonHugeist: this is a compatibility-Option for exiting Applictions.
626  Zeos is now able to preprepare direct insered SQL-Statements.
627  Means do the UTF8-preparation if the CharacterSet was choosen.
628  So we do not need to do the SQLString + UTF8Encode(Edit1.Test) for example.
629  @result True if coPreprepareSQL was choosen in the TZAbstractConnection
630 }
631 function TZAbstractConnection.GetAutoEncodeStrings: Boolean;
632 begin
633  {$IFDEF UNICODE}
634  Result := True;
635  {$ELSE}
636  Result := ConSettings.AutoEncode;
637  {$ENDIF}
638 end;
639 
640 procedure TZAbstractConnection.SetAutoEncodeStrings(const Value: Boolean);
641 begin
642  {$IFNDEF UNICODE}
643  ConSettings.AutoEncode := Value;
644  {$ENDIF}
645 end;
646 
647 {**
648  EgonHugeist and MDeams: The old deprecadet constructor which was used
649  from the descendant classes. We left him here for compatibility reasons to
650  exesting projects which using the DbcConnections directly
651 
652  Constructs this object and assignes the main properties.
653  @param Driver the parent ZDBC driver.
654  @param Url a connection URL.
655  @param PlainDriver a versioned ZPlainDriver object interface.
656  @param HostName a name of the host.
657  @param Port a port number (0 for default port).
658  @param Database a name pof the database.
659  @param User a user name.
660  @param Password a user password.
661  @param Info a string list with extra connection parameters.
662 }
663 {$WARNINGS OFF} //suppress the deprecatad warning of calling create from internal
664 constructor TZAbstractConnection.Create(Driver: IZDriver; const Url: string;
665  PlainDriver: IZPlainDriver;
666  const HostName: string; Port: Integer; const Database: string;
667  const User: string; const Password: string; Info: TStrings);
668 var
669  TempURL: TZURL;
670 begin
671  TempURL := TZURL.Create(Url, HostName, Port, Database, User, Password, Info);
672  Create(TempURL);
673  TempURL.Free;
674 end;
675 {$WARNINGS OFF}
676 
677 {**
678  Constructs this object and assignes the main properties.
679  @param Url a connection ZURL-class which exports all connection parameters.
680 }
681 constructor TZAbstractConnection.Create(const ZUrl: TZURL);
682 begin
683  FClosed := True;
684  if not assigned(ZUrl) then
685  raise Exception.Create('ZUrl is not assigned!')
686  else
687  FURL := TZURL.Create();
688  FDriver := DriverManager.GetDriver(ZURL.URL);
689  FIZPlainDriver := FDriver.GetPlainDriver(ZUrl);
690 
691  FURL.OnPropertiesChange := OnPropertiesChange;
692  FURL.URL := ZUrl.URL;
693 
694  FClientCodePage := Info.Values['codepage'];
695  {CheckCharEncoding}
696  ConSettings := New(PZConSettings);
697 
698  SetConSettingsFromInfo(Info);
699  CheckCharEncoding(FClientCodePage, True);
700 
701  FAutoCommit := True;
702  FReadOnly := False; //EH: Changed! We definitelly did newer ever open a ReadOnly connection by default!
703  FTransactIsolationLevel := tiNone;
704  FUseMetadata := True;
705  InternalCreate;
706  {$IFDEF ZEOS_TEST_ONLY}
707  FTestMode := 0;
708  {$ENDIF}
709 end;
710 
711 {**
712  Destroys this object and cleanups the memory.
713 }
714 destructor TZAbstractConnection.Destroy;
715 begin
716  if not FClosed then
717  Close;
718  FreeAndNil(FMetadata);
719  FURL.Free;
720  FIZPlainDriver := nil;
721  FDriver := nil;
722  if Assigned(ConSettings) then
723  Dispose(ConSettings);
724  inherited Destroy;
725 end;
726 
727 {**
728  Opens a connection to database server with specified parameters.
729 }
730 procedure TZAbstractConnection.Open;
731 begin
732  FClosed := False;
733 end;
734 
735 {**
736  Raises unsupported operation exception.
737 }
738 procedure TZAbstractConnection.RaiseUnsupportedException;
739 begin
740  raise EZSQLException.Create(SUnsupportedOperation);
741 end;
742 
743 {**
744  Creates a <code>Statement</code> object for sending
745  SQL statements to the database.
746  SQL statements without parameters are normally
747  executed using Statement objects. If the same SQL statement
748  is executed many times, it is more efficient to use a
749  <code>PreparedStatement</code> object.
750  <P>
751  Result sets created using the returned <code>Statement</code>
752  object will by default have forward-only type and read-only concurrency.
753 
754  @return a new Statement object
755 }
756 function TZAbstractConnection.CreateStatement: IZStatement;
757 begin
758  Result := CreateStatementWithParams(nil);
759 end;
760 
761 {**
762  Creates a <code>Statement</code> object for sending
763  SQL statements to the database.
764  SQL statements without parameters are normally
765  executed using Statement objects. If the same SQL statement
766  is executed many times, it is more efficient to use a
767  <code>PreparedStatement</code> object.
768  <P>
769  Result sets created using the returned <code>Statement</code>
770  object will by default have forward-only type and read-only concurrency.
771 
772  @param Info a statement parameters.
773  @return a new Statement object
774 }
775 function TZAbstractConnection.CreateStatementWithParams(Info: TStrings):
776  IZStatement;
777 var UsedInfo: TStrings;
778 begin
779  UsedInfo := Info;
780  If StrToBoolEx(GetInfo.Values['preferprepared']) then
781  begin
782  If UsedInfo = nil then
783  UsedInfo := TSTringList.Create;
784  UsedInfo.Append('preferprepared=TRUE');
785  end;
786  Result := CreateRegularStatement(UsedInfo);
787  if UsedInfo <> Info then UsedInfo.Free;
788 end;
789 
790 {**
791  Creates a regular statement object.
792  @param SQL a SQL query string.
793  @param Info a statement parameters.
794  @returns a created statement.
795 }
796 function TZAbstractConnection.CreateRegularStatement(
797  Info: TStrings): IZStatement;
798 begin
799  Result := nil;
800  RaiseUnsupportedException;
801 end;
802 
803 {**
804  Creates a <code>PreparedStatement</code> object for sending
805  parameterized SQL statements to the database.
806 
807  A SQL statement with or without IN parameters can be
808  pre-compiled and stored in a PreparedStatement object. This
809  object can then be used to efficiently execute this statement
810  multiple times.
811 
812  <P><B>Note:</B> This method is optimized for handling
813  parametric SQL statements that benefit from precompilation. If
814  the driver supports precompilation,
815  the method <code>prepareStatement</code> will send
816  the statement to the database for precompilation. Some drivers
817  may not support precompilation. In this case, the statement may
818  not be sent to the database until the <code>PreparedStatement</code> is
819  executed. This has no direct effect on users; however, it does
820  affect which method throws certain SQLExceptions.
821 
822  Result sets created using the returned PreparedStatement will have
823  forward-only type and read-only concurrency, by default.
824 
825  @param sql a SQL statement that may contain one or more '?' IN
826  parameter placeholders
827  @return a new PreparedStatement object containing the
828  pre-compiled statement
829 }
830 function TZAbstractConnection.PrepareStatement(const SQL: string): IZPreparedStatement;
831 begin
832  Result := CreatePreparedStatement(SQL, nil);
833 end;
834 
835 {**
836  Creates a <code>PreparedStatement</code> object for sending
837  parameterized SQL statements to the database.
838 
839  @param SQL a SQL statement that may contain one or more '?' IN
840  parameter placeholders
841  @param Info a statement parameters.
842  @return a new PreparedStatement object containing the
843  pre-compiled statement
844 }
845 function TZAbstractConnection.PrepareStatementWithParams(const SQL: string;
846  Info: TStrings): IZPreparedStatement;
847 var UsedInfo: TStrings;
848 begin
849  UsedInfo := Info;
850  If StrToBoolEx(GetInfo.Values['preferprepared']) then
851  begin
852  If UsedInfo = nil then
853  UsedInfo := TSTringList.Create;
854  UsedInfo.Append('preferprepared=TRUE');
855  end;
856  Result := CreatePreparedStatement(SQL, UsedInfo);
857  if UsedInfo <> Info then UsedInfo.Free;
858 end;
859 
860 procedure TZAbstractConnection.PrepareTransaction(const transactionid: string);
861 begin
862  RaiseUnsupportedException;
863 end;
864 
865 {**
866  Creates a prepared statement object.
867  @param SQL a SQL query string.
868  @param Info a statement parameters.
869  @returns a created statement.
870 }
871 function TZAbstractConnection.CreatePreparedStatement(const SQL: string;
872  Info: TStrings): IZPreparedStatement;
873 begin
874  Result := nil;
875  RaiseUnsupportedException;
876 end;
877 
878 {**
879  Creates a <code>CallableStatement</code> object for calling
880  database stored procedures.
881  The <code>CallableStatement</code> object provides
882  methods for setting up its IN and OUT parameters, and
883  methods for executing the call to a stored procedure.
884 
885  <P><B>Note:</B> This method is optimized for handling stored
886  procedure call statements. Some drivers may send the call
887  statement to the database when the method <code>prepareCall</code>
888  is done; others
889  may wait until the <code>CallableStatement</code> object
890  is executed. This has no
891  direct effect on users; however, it does affect which method
892  throws certain SQLExceptions.
893 
894  Result sets created using the returned CallableStatement will have
895  forward-only type and read-only concurrency, by default.
896 
897  @param sql a SQL statement that may contain one or more '?'
898  parameter placeholders. Typically this statement is a JDBC
899  function call escape string.
900  @return a new CallableStatement object containing the
901  pre-compiled SQL statement
902 }
903 
904 function TZAbstractConnection.PrepareCall(
905  const SQL: string): IZCallableStatement;
906 begin
907  Result := CreateCallableStatement(SQL, nil);
908 end;
909 
910 {**
911  Creates a <code>CallableStatement</code> object for calling
912  database stored procedures.
913  The <code>CallableStatement</code> object provides
914  methods for setting up its IN and OUT parameters, and
915  methods for executing the call to a stored procedure.
916 
917  @param SQL a SQL statement that may contain one or more '?'
918  parameter placeholders. Typically this statement is a JDBC
919  function call escape string.
920  @param Info a statement parameters.
921  @return a new CallableStatement object containing the
922  pre-compiled SQL statement
923 }
924 function TZAbstractConnection.PrepareCallWithParams(const SQL: string;
925  Info: TStrings): IZCallableStatement;
926 var UsedInfo: TStrings;
927 begin
928  UsedInfo := Info;
929  If StrToBoolEx(GetInfo.Values['preferprepared']) then
930  begin
931  If UsedInfo = nil then
932  UsedInfo := TSTringList.Create;
933  UsedInfo.Append('preferprepared=TRUE');
934  end;
935  Result := CreateCallableStatement(SQL, UsedInfo);
936  if UsedInfo <> Info then UsedInfo.Free;
937 end;
938 
939 {**
940  Creates a callable statement object.
941  @param SQL a SQL query string.
942  @param Info a statement parameters.
943  @returns a created statement.
944 }
945 function TZAbstractConnection.CreateCallableStatement(const SQL: string;
946  Info: TStrings): IZCallableStatement;
947 begin
948  Result := nil;
949  RaiseUnsupportedException;
950 end;
951 
952 {**
953  Creates an object to send/recieve notifications from SQL server.
954  @param Event an event name.
955  @returns a created notification object.
956 }
957 function TZAbstractConnection.CreateNotification(const Event: string): IZNotification;
958 begin
959  Result := nil;
960  RaiseUnsupportedException;
961 end;
962 
963 {**
964  Creates a sequence generator object.
965  @param Sequence a name of the sequence generator.
966  @param BlockSize a number of unique keys requested in one trip to SQL server.
967  @returns a created sequence object.
968 }
969 function TZAbstractConnection.CreateSequence(const Sequence: string;
970  BlockSize: Integer): IZSequence;
971 begin
972  Result := nil;
973  RaiseUnsupportedException;
974 end;
975 
976 {**
977  Converts the given SQL statement into the system's native SQL grammar.
978  A driver may convert the JDBC sql grammar into its system's
979  native SQL grammar prior to sending it; this method returns the
980  native form of the statement that the driver would have sent.
981 
982  @param sql a SQL statement that may contain one or more '?'
983  parameter placeholders
984  @return the native form of this statement
985 }
986 function TZAbstractConnection.NativeSQL(const SQL: string): string;
987 begin
988  Result := SQL;
989 end;
990 
991 {**
992  Sets this connection's auto-commit mode.
993  If a connection is in auto-commit mode, then all its SQL
994  statements will be executed and committed as individual
995  transactions. Otherwise, its SQL statements are grouped into
996  transactions that are terminated by a call to either
997  the method <code>commit</code> or the method <code>rollback</code>.
998  By default, new connections are in auto-commit mode.
999 
1000  The commit occurs when the statement completes or the next
1001  execute occurs, whichever comes first. In the case of
1002  statements returning a ResultSet, the statement completes when
1003  the last row of the ResultSet has been retrieved or the
1004  ResultSet has been closed. In advanced cases, a single
1005  statement may return multiple results as well as output
1006  parameter values. In these cases the commit occurs when all results and
1007  output parameter values have been retrieved.
1008 
1009  @param autoCommit true enables auto-commit; false disables auto-commit.
1010 }
1011 procedure TZAbstractConnection.SetAutoCommit(Value: Boolean);
1012 begin
1013  FAutoCommit := Value;
1014 end;
1015 
1016 {**
1017  Gets the current auto-commit state.
1018  @return the current state of auto-commit mode
1019  @see #setAutoCommit
1020 }
1021 function TZAbstractConnection.GetAutoCommit: Boolean;
1022 begin
1023  Result := FAutoCommit;
1024 end;
1025 
1026 {**
1027  Makes all changes made since the previous
1028  commit/rollback permanent and releases any database locks
1029  currently held by the Connection. This method should be
1030  used only when auto-commit mode has been disabled.
1031  @see #setAutoCommit
1032 }
1033 procedure TZAbstractConnection.Commit;
1034 begin
1035  RaiseUnsupportedException;
1036 end;
1037 
1038 procedure TZAbstractConnection.CommitPrepared(const transactionid: string);
1039 begin
1040  RaiseUnsupportedException;
1041 end;
1042 
1043 {**
1044  Drops all changes made since the previous
1045  commit/rollback and releases any database locks currently held
1046  by this Connection. This method should be used only when auto-
1047  commit has been disabled.
1048  @see #setAutoCommit
1049 }
1050 procedure TZAbstractConnection.Rollback;
1051 begin
1052  RaiseUnsupportedException;
1053 end;
1054 
1055 procedure TZAbstractConnection.RollbackPrepared(const transactionid: string);
1056 begin
1057  RaiseUnsupportedException;
1058 end;
1059 
1060 {**
1061  Ping Current Connection's server, if client was disconnected,
1062  the connection is resumed.
1063  @return 0 if succesfull or error code if any error occurs
1064 }
1065 function TZAbstractConnection.PingServer: Integer;
1066 begin
1067  Result := 1;
1068  RaiseUnsupportedException;
1069 end;
1070 
1071 {**
1072  Escape a string so it's acceptable for the Connection's server.
1073  @param value string that should be escaped
1074  @return Escaped string
1075 }
1076 function TZAbstractConnection.EscapeString(Value : RawByteString) : RawByteString;
1077 begin
1078  Result := AnsiString(EncodeCString(String(Value)));
1079 end;
1080 
1081 {**
1082  Releases a Connection's database and JDBC resources
1083  immediately instead of waiting for
1084  them to be automatically released.
1085 
1086  <P><B>Note:</B> A Connection is automatically closed when it is
1087  garbage collected. Certain fatal errors also result in a closed
1088  Connection.
1089 }
1090 
1091 procedure TZAbstractConnection.Close;
1092 begin
1093  if FDisposeCodePage then
1094  begin
1095  Dispose(ConSettings^.ClientCodePage);
1096  ConSettings^.ClientCodePage := nil;
1097  FDisposeCodePage := False;
1098  end;
1099  FClosed := True;
1100 end;
1101 
1102 {**
1103  Tests to see if a Connection is closed.
1104  @return true if the connection is closed; false if it's still open
1105 }
1106 function TZAbstractConnection.IsClosed: Boolean;
1107 begin
1108  Result := FClosed;
1109 end;
1110 
1111 {**
1112  Gets the parent ZDBC driver.
1113  @returns the parent ZDBC driver interface.
1114 }
1115 function TZAbstractConnection.GetDriver: IZDriver;
1116 begin
1117  Result := FDriver;
1118 end;
1119 
1120 {**
1121  Gets the plain driver.
1122  @returns the plain driver interface.
1123 }
1124 function TZAbstractConnection.GetIZPlainDriver: IZPlainDriver;
1125 begin
1126  result := FIZPlainDriver;
1127 end;
1128 
1129 {**
1130  Gets the metadata regarding this connection's database.
1131  A Connection's database is able to provide information
1132  describing its tables, its supported SQL grammar, its stored
1133  procedures, the capabilities of this connection, and so on. This
1134  information is made available through a DatabaseMetaData
1135  object.
1136 
1137  @return a DatabaseMetaData object for this Connection
1138 }
1139 function TZAbstractConnection.GetMetadata: IZDatabaseMetadata;
1140 begin
1141  Result := FMetadata as IZDatabaseMetadata;
1142 end;
1143 
1144 {**
1145  Gets a connection parameters.
1146  @returns a list with connection parameters.
1147 }
1148 function TZAbstractConnection.GetParameters: TStrings;
1149 begin
1150  Result := Info;
1151 end;
1152 
1153 {**
1154  Gets the client's full version number. Initially this should be 0.
1155  The format of the version resturned must be XYYYZZZ where
1156  X = Major version
1157  YYY = Minor version
1158  ZZZ = Sub version
1159  @return this clients's full version number
1160 }
1161 function TZAbstractConnection.GetClientVersion: Integer;
1162 begin
1163  Result := 0;
1164 end;
1165 
1166 {**
1167  Gets the host's full version number. Initially this should be 0.
1168  The format of the version returned must be XYYYZZZ where
1169  X = Major version
1170  YYY = Minor version
1171  ZZZ = Sub version
1172  @return this server's full version number
1173 }
1174 function TZAbstractConnection.GetHostVersion: Integer;
1175 begin
1176  Result := 0;
1177 end;
1178 
1179 function TZAbstractConnection.GetDescription: AnsiString;
1180 begin
1181  PlainDriver.GetDescription;
1182 end;
1183 
1184 {END ADDED by fduenas 15-06-2006}
1185 
1186 {**
1187  Puts this connection in read-only mode as a hint to enable
1188  database optimizations.
1189 
1190  <P><B>Note:</B> This method cannot be called while in the
1191  middle of a transaction.
1192 
1193  @param readOnly true enables read-only mode; false disables
1194  read-only mode.
1195 }
1196 procedure TZAbstractConnection.SetReadOnly(ReadOnly: Boolean);
1197 begin
1198  FReadOnly := ReadOnly;
1199 end;
1200 
1201 {**
1202  Tests to see if the connection is in read-only mode.
1203  @return true if connection is read-only and false otherwise
1204 }
1205 function TZAbstractConnection.IsReadOnly: Boolean;
1206 begin
1207  Result := FReadOnly;
1208 end;
1209 
1210 {**
1211  Sets a catalog name in order to select
1212  a subspace of this Connection's database in which to work.
1213  If the driver does not support catalogs, it will
1214  silently ignore this request.
1215 }
1216 procedure TZAbstractConnection.SetCatalog(const Catalog: string);
1217 begin
1218 end;
1219 
1220 {**
1221  Returns the Connection's current catalog name.
1222  @return the current catalog name or null
1223 }
1224 function TZAbstractConnection.GetCatalog: string;
1225 begin
1226  Result := '';
1227 end;
1228 
1229 {**
1230  Attempts to change the transaction isolation level to the one given.
1231  The constants defined in the interface <code>Connection</code>
1232  are the possible transaction isolation levels.
1233 
1234  <P><B>Note:</B> This method cannot be called while
1235  in the middle of a transaction.
1236 
1237  @param level one of the TRANSACTION_* isolation values with the
1238  exception of TRANSACTION_NONE; some databases may not support other values
1239  @see DatabaseMetaData#supportsTransactionIsolationLevel
1240 }
1241 procedure TZAbstractConnection.SetTransactionIsolation(
1242  Level: TZTransactIsolationLevel);
1243 begin
1244  FTransactIsolationLevel := Level;
1245 end;
1246 
1247 {**
1248  Gets this Connection's current transaction isolation level.
1249  @return the current TRANSACTION_* mode value
1250 }
1251 function TZAbstractConnection.GetTransactionIsolation: TZTransactIsolationLevel;
1252 begin
1253  Result := FTransactIsolationLevel;
1254 end;
1255 
1256 {**
1257  Returns the first warning reported by calls on this Connection.
1258  <P><B>Note:</B> Subsequent warnings will be chained to this
1259  SQLWarning.
1260  @return the first SQLWarning or null
1261 }
1262 function TZAbstractConnection.GetWarnings: EZSQLWarning;
1263 begin
1264  Result := nil;
1265 end;
1266 
1267 {**
1268  Clears all warnings reported for this <code>Connection</code> object.
1269  After a call to this method, the method <code>getWarnings</code>
1270  returns null until a new warning is reported for this Connection.
1271 }
1272 procedure TZAbstractConnection.ClearWarnings;
1273 begin
1274 end;
1275 
1276 function TZAbstractConnection.UseMetadata: boolean;
1277 begin
1278  result := FUseMetadata;
1279 end;
1280 
1281 procedure TZAbstractConnection.SetUseMetadata(Value: Boolean);
1282 begin
1283  FUseMetadata := Value;
1284 end;
1285 
1286 {$IFDEF ZEOS_TEST_ONLY}
1287 function TZAbstractConnection.GetTestMode: Byte;
1288 begin
1289  Result := FTestMode;
1290 end;
1291 
1292 procedure TZAbstractConnection.SetTestMode(Mode: Byte);
1293 begin
1294  FTestMode := Mode;
1295 end;
1296 {$ENDIF}
1297 
1298 {**
1299  EgonHugeist:
1300  Returns the BinaryString in a Tokenizer-detectable kind
1301  If the Tokenizer don't need to predetect it Result = BinaryString
1302  @param Value represents the Binary-String
1303  @param EscapeMarkSequence represents a Tokenizer detectable EscapeSequence (Len >= 3)
1304  @result the detectable Binary String
1305 }
1306 function TZAbstractConnection.GetBinaryEscapeString(const Value: RawByteString): String;
1307 begin
1308  if GetAutoEncodeStrings then //Set detect-sequence only if Prepreparing should be done else it's not server-understandable.
1309  Result := Self.GetDriver.GetTokenizer.AnsiGetEscapeString(GetSQLHexString(PAnsiChar(Value), Length(Value)))
1310  else
1311  Result := GetSQLHexString(PAnsiChar(Value), Length(Value));
1312 end;
1313 
1314 function TZAbstractConnection.GetBinaryEscapeString(const Value: TByteDynArray): String;
1315 begin
1316  if GetAutoEncodeStrings then //Set detect-sequence only if Prepreparing should be done else it's not server-understandable.
1317  Result := Self.GetDriver.GetTokenizer.AnsiGetEscapeString(GetSQLHexString(PAnsiChar(Value), Length(Value)))
1318  else
1319  Result := GetSQLHexString(PAnsiChar(Value), Length(Value));
1320 end;
1321 
1322 function TZAbstractConnection.GetEscapeString(const Value: ZWideString): ZWideString;
1323 begin
1324  if GetAutoEncodeStrings then
1325  if StartsWith(Value, '''') and EndsWith(Value, '''') then
1326  Result := GetDriver.GetTokenizer.GetEscapeString(Value)
1327  else
1328  {$IFDEF UNICODE}
1329  Result := AnsiQuotedStr(Value, #39)
1330  {$ELSE}
1331  Result := ZDbcUnicodeString(GetDriver.GetTokenizer.GetEscapeString(AnsiQuotedStr(ZPlainString(Value), #39)))
1332  {$ENDIF}
1333  else
1334  if StartsWith(Value, '''') and EndsWith(Value, '''') then
1335  Result := Value
1336  else
1337  {$IFDEF UNICODE}
1338  Result := AnsiQuotedStr(Value, #39);
1339  {$ELSE}
1340  Result := ZDbcUnicodeString(AnsiQuotedStr(ZPlainString(Value), #39));
1341  {$ENDIF}
1342 end;
1343 
1344 function TZAbstractConnection.GetEscapeString(const Value: RawByteString): RawByteString;
1345 begin
1346  if GetAutoEncodeStrings then
1347  if StartsWith(Value, '''') and EndsWith(Value, '''') then
1348  Result := {$IFNDEF UNICODE}GetDriver.GetTokenizer.GetEscapeString{$ENDIF}(Value)
1349  else
1350  {$IFDEF WITH_UNITANSISTRINGS}
1351  AnsiStrings.AnsiQuotedStr(Value, #39)
1352  {$ELSE}
1353  Result := GetDriver.GetTokenizer.GetEscapeString(AnsiQuotedStr(ZDbcString(Value), #39))
1354  {$ENDIF}
1355  else
1356  if StartsWith(Value, '''') and EndsWith(Value, '''') then
1357  Result := Value
1358  else
1359  Result := {$IFDEF WITH_UNITANSISTRINGS}AnsiStrings.{$ENDIF}AnsiQuotedStr(Value, #39);
1360 end;
1361 
1362 {**
1363  Result 100% Compiler-Compatible
1364  And sets it Result to ClientCodePage by calling the
1365  PlainDriver.GetClientCodePageInformations function
1366 
1367  @param ClientCharacterSet the CharacterSet which has to be checked
1368  @result PZCodePage see ZCompatible.pas
1369 }
1370 function TZAbstractConnection.GetClientCodePageInformations: PZCodePage; //EgonHugeist
1371 begin
1372  Result := ConSettings.ClientCodePage
1373 end;
1374 
1375 procedure TZAbstractConnection.OnPropertiesChange(Sender: TObject);
1376 begin
1377  // do nothing in base class
1378 end;
1379 
1380 { TZAbstractNotification }
1381 
1382 {**
1383  Creates this object and assignes the main properties.
1384  @param Connection a database connection object.
1385  @param EventName a name of the SQL event.
1386 }
1387 constructor TZAbstractNotification.Create(Connection: IZConnection;
1388  EventName: string);
1389 begin
1390  FConnection := Connection;
1391  FEventName := EventName;
1392 end;
1393 
1394 {**
1395  Gets an event name.
1396  @return an event name for this notification.
1397 }
1398 function TZAbstractNotification.GetEvent: string;
1399 begin
1400  Result := FEventName;
1401 end;
1402 
1403 {**
1404  Sets a listener to the specified event.
1405 }
1406 procedure TZAbstractNotification.Listen;
1407 begin
1408 end;
1409 
1410 {**
1411  Removes a listener to the specified event.
1412 }
1413 procedure TZAbstractNotification.Unlisten;
1414 begin
1415 end;
1416 
1417 {**
1418  Checks for any pending events.
1419  @return a string with incoming events??
1420 }
1421 function TZAbstractNotification.CheckEvents: string;
1422 begin
1423  Result := '';
1424 end;
1425 
1426 {**
1427  Sends a notification string.
1428 }
1429 procedure TZAbstractNotification.DoNotify;
1430 begin
1431 end;
1432 
1433 {**
1434  Returns the <code>Connection</code> object
1435  that produced this <code>Statement</code> object.
1436  @return the connection that produced this statement
1437 }
1438 function TZAbstractNotification.GetConnection: IZConnection;
1439 begin
1440  Result := FConnection;
1441 end;
1442 
1443 { TZAbstractSequence }
1444 
1445 {**
1446  Creates this sequence object.
1447  @param Connection an SQL connection interface.
1448  @param Name a name of the sequence generator.
1449  @param BlockSize a number of unique keys requested in one trip to server.
1450 }
1451 constructor TZAbstractSequence.Create(Connection: IZConnection;
1452  Name: string; BlockSize: Integer);
1453 begin
1454  FConnection := Connection;
1455  FName := Name;
1456  FBlockSize := BlockSize;
1457 end;
1458 
1459 {**
1460  Returns the <code>Connection</code> object
1461  that produced this <code>Statement</code> object.
1462  @return the connection that produced this statement
1463 }
1464 function TZAbstractSequence.GetConnection: IZConnection;
1465 begin
1466  Result := FConnection;
1467 end;
1468 
1469 {**
1470  Returns a name of the sequence generator.
1471  @return a name of this sequence generator.
1472 }
1473 function TZAbstractSequence.GetName: string;
1474 begin
1475  Result := FName;
1476 end;
1477 
1478 {**
1479  Returns the assigned block size for this sequence.
1480  @return the assigned block size.
1481 }
1482 function TZAbstractSequence.GetBlockSize: Integer;
1483 begin
1484  Result := FBlockSize;
1485 end;
1486 
1487 {**
1488  Gets the current unique key generated by this sequence.
1489  @param the last generated unique key.
1490 }
1491 function TZAbstractSequence.GetCurrentValue: Int64;
1492 begin
1493  Result := 0;
1494 end;
1495 
1496 {
1497 function TZAbstractSequence.GetCurrentValueSQL: String;
1498 begin
1499  result:='IMPLEMENT';
1500 end;
1501 }
1502 
1503 {**
1504  Gets the next unique key generated by this sequence.
1505  @param the next generated unique key.
1506 }
1507 function TZAbstractSequence.GetNextValue: Int64;
1508 begin
1509  Result := 0;
1510 end;
1511 
1512 {
1513 function TZAbstractSequence.GetNextValueSQL: String;
1514 begin
1515  result:='IMPLEMENT';
1516 end;
1517 }
1518 
1519 {**
1520  Sets the block size for this sequence.
1521  @param Value the block size.
1522 }
1523 procedure TZAbstractSequence.SetBlockSize(const Value: Integer);
1524 begin
1525  FBlockSize := Value;
1526 end;
1527 
1528 {**
1529  Sets a name of the sequence generator.
1530  @param Value a name of this sequence generator.
1531 }
1532 procedure TZAbstractSequence.SetName(const Value: string);
1533 begin
1534  FName := Value;
1535 end;
1536 
1537 end.