Стартовый пул

This commit is contained in:
2024-04-02 08:46:59 +03:00
parent fd57fffd3a
commit 3bb34d000b
5591 changed files with 3291734 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
[FileVersion]
Version=6.0
[Compiler]
A=8
B=0
C=1
D=1
E=0
F=0
G=1
H=1
I=1
J=0
K=0
L=1
M=0
N=1
O=1
P=1
Q=0
R=0
S=0
T=0
U=0
V=1
W=0
X=1
Y=1
Z=1
ShowHints=1
ShowWarnings=1
UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
[Linker]
MapFile=0
OutputObjs=0
ConsoleApp=1
DebugInfo=0
RemoteSymbols=0
MinStackSize=16384
MaxStackSize=1048576
ImageBase=4194304
ExeDescription=
[Directories]
OutputDir=
UnitOutputDir=
PackageDLLOutputDir=
PackageDCPOutputDir=
SearchPath=
Packages=vcl;rtl;vclx;VclSmp;vclshlctrls;dbrtl;adortl;vcldb;bdertl;vcldbx;dsnap;cds;bdecds;teeui;teedb;tee;teeqr;ibxpress;visualclx;visualdbclx;vclie;xmlrtl;inet;inetdbbde;inetdbxpress;inetdb;nmfast;dbexpress;dbxcds;indy;dclOffice2k;soaprtl;ZCore;ZParseSql;ZPlain;ZDbc;ZComponent;ZTestFramework
Conditionals=
DebugSourceDirs=
UsePackages=0
[Parameters]
RunParams=
HostApplication=
Launcher=
UseLauncher=0
DebugCWD=
[Language]
ActiveLang=
ProjectLang=
RootDir=
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=1038
CodePage=1250
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlUnitAliases]
Count=1
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
[HistoryLists\hlSearchPath]
Count=1
Item0=$(DELPHI)\Lib\Debug

View File

@@ -0,0 +1,13 @@
program DbcDemo;
uses
Forms,
DbcDemoMain in 'DbcDemoMain.pas' {frmDBCDemo};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TfrmDBCDemo, frmDBCDemo);
Application.Run;
end.

View File

@@ -0,0 +1,211 @@
object frmDBCDemo: TfrmDBCDemo
Left = 380
Top = 201
Caption = 'DBC demo'
ClientHeight = 622
ClientWidth = 720
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object Pannel1: TPanel
Left = 0
Top = 0
Width = 720
Height = 57
Align = alTop
TabOrder = 0
object Label1: TLabel
Left = 8
Top = 8
Width = 39
Height = 13
Caption = 'Protocol'
end
object Label2: TLabel
Left = 115
Top = 8
Width = 48
Height = 13
Caption = 'Hostname'
end
object Label3: TLabel
Left = 228
Top = 8
Width = 19
Height = 13
Caption = 'Port'
end
object Label4: TLabel
Left = 282
Top = 8
Width = 46
Height = 13
Caption = 'Database'
end
object Label5: TLabel
Left = 395
Top = 8
Width = 48
Height = 13
Caption = 'Username'
end
object Label6: TLabel
Left = 507
Top = 8
Width = 46
Height = 13
Caption = 'Password'
end
object Button1: TButton
Left = 632
Top = 21
Width = 75
Height = 25
Caption = 'Connect'
TabOrder = 0
OnClick = Button1Click
end
object cobProtocol: TComboBox
Left = 8
Top = 24
Width = 105
Height = 21
ItemHeight = 13
TabOrder = 1
end
object edtHostName: TEdit
Left = 115
Top = 24
Width = 110
Height = 21
TabOrder = 2
Text = 'localhost'
end
object spePort: TSpinEdit
Left = 228
Top = 24
Width = 51
Height = 22
MaxValue = 0
MinValue = 0
TabOrder = 3
Value = 0
end
object edtDatabase: TEdit
Left = 282
Top = 24
Width = 110
Height = 21
TabOrder = 4
Text = 'c:\zeoslib.fdb'
end
object edtUsername: TEdit
Left = 395
Top = 24
Width = 110
Height = 21
TabOrder = 5
Text = 'sysdba'
end
object edtPassword: TEdit
Left = 507
Top = 24
Width = 110
Height = 21
TabOrder = 6
Text = 'masterkey'
end
end
object sgResults: TStringGrid
Left = 0
Top = 178
Width = 720
Height = 444
Align = alClient
ColCount = 1
DefaultRowHeight = 18
FixedCols = 0
RowCount = 2
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing]
TabOrder = 1
OnSelectCell = sgResultsSelectCell
OnSetEditText = sgResultsSetEditText
end
object Panel1: TPanel
Left = 0
Top = 57
Width = 720
Height = 80
Align = alTop
Caption = 'Panel1'
TabOrder = 2
object Label7: TLabel
Left = 8
Top = 8
Width = 70
Height = 13
Caption = 'SQL statement'
end
object memSQL: TMemo
Left = 7
Top = 23
Width = 612
Height = 50
Lines.Strings = (
'select * from people')
TabOrder = 0
end
object Button2: TButton
Left = 632
Top = 24
Width = 75
Height = 25
Caption = 'Execute'
TabOrder = 1
OnClick = Button2Click
end
end
object Panel2: TPanel
Left = 0
Top = 137
Width = 720
Height = 41
Align = alTop
TabOrder = 3
object Button3: TButton
Left = 168
Top = 8
Width = 75
Height = 25
Caption = 'Delete'
TabOrder = 2
OnClick = Button3Click
end
object Button4: TButton
Left = 88
Top = 8
Width = 75
Height = 25
Caption = 'Post'
TabOrder = 1
OnClick = Button4Click
end
object Button5: TButton
Left = 8
Top = 8
Width = 75
Height = 25
Caption = 'Append'
TabOrder = 0
OnClick = Button5Click
end
end
end

View File

@@ -0,0 +1,265 @@
unit DbcDemoMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Spin, Grids;
type
TfrmDBCDemo = class(TForm)
Button1: TButton;
cobProtocol: TComboBox;
Pannel1: TPanel;
Label1: TLabel;
edtHostName: TEdit;
Label2: TLabel;
spePort: TSpinEdit;
Label3: TLabel;
edtDatabase: TEdit;
Label4: TLabel;
edtUsername: TEdit;
Label5: TLabel;
Label6: TLabel;
edtPassword: TEdit;
sgResults: TStringGrid;
Panel1: TPanel;
memSQL: TMemo;
Label7: TLabel;
Button2: TButton;
Panel2: TPanel;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure sgResultsSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure sgResultsSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: String);
procedure Button5Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmDBCDemo: TfrmDBCDemo;
implementation
uses ZClasses, ZDbcIntfs, ZCompatibility,
//Only those drivers will be supported for which you load the proper unit, see below
ZDbcMySql, ZDbcInterbase6, ZDbcPostgreSql, ZDbcDBLib;
{$R *.dfm}
var
Connection: IZConnection;
ResultSet: IZResultSet;
LastRowNr: Integer;//This is to detect row nr change
InsertState: Boolean;
{**
This is just fills the protocols combobox with the available protocols
}
procedure TfrmDBCDemo.FormShow(Sender: TObject);
var
I, J: Integer;
Drivers: IZCollection;
Protocols: TStringDynArray;
begin
cobProtocol.Clear;
Drivers := DriverManager.GetDrivers;
for I := 0 to Drivers.Count - 1 do
begin
Protocols := (Drivers.Items[I] as IZDriver).GetSupportedProtocols;
for J := 0 to High(Protocols) do
cobProtocol.Items.Add(Protocols[J]);
end;
cobProtocol.Sorted := True;
end;
{**
Close the connection if active
}
procedure TfrmDBCDemo.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Assigned(Connection) then
if not Connection.IsClosed then
Connection.Close;
end;
{**
The connection is made here.
You can see how the connection string is generated and how to connect to the database.
}
procedure TfrmDBCDemo.Button1Click(Sender: TObject);
var
Url: string;
begin
if spePort.Value <> 0 then
begin
Url := Format('zdbc:%s://%s:%d/%s?UID=%s;PWD=%s', [cobProtocol.Text, edtHostName.Text,
spePort.Value, edtDatabase.Text, edtUserName.Text, edtPassword.Text]);
end
else
begin
Url := Format('zdbc:%s://%s/%s?UID=%s;PWD=%s', [cobProtocol.Text, edtHostName.Text,
edtDatabase.Text, edtUserName.Text, edtPassword.Text]);
end;
Connection := DriverManager.GetConnectionWithParams(Url, nil);
Connection.SetAutoCommit(True);
Connection.SetTransactionIsolation(tiReadCommitted);
Connection.Open;
end;
{**
A statement is executed here
If the statement returns a resultset then the resultset is loaded into the stringgrid.
There methods for access by name also, for example GetStringByName
}
procedure TfrmDBCDemo.Button2Click(Sender: TObject);
var
Statement: IZStatement;
I: Integer;
Value: string;
begin
Statement := Connection.CreateStatement;
//This is not neccesseary if you do not want to modify the data
Statement.SetResultSetConcurrency(rcUpdatable);
ResultSet := Statement.ExecuteQuery(memSQL.Text);
sgResults.RowCount := 1;
sgResults.ColCount := 1;
//Was any resultset returned?
if Assigned(ResultSet) then
begin
sgResults.ColCount := ResultSet.GetMetadata.GetColumnCount;
for I := 1 to ResultSet.GetMetadata.GetColumnCount do
sgResults.Cells[I - 1, 0] := ResultSet.GetMetadata.GetColumnName(I);
//Make a cycle for each record in the resultset
while ResultSet.Next do
begin
sgResults.RowCount := sgResults.RowCount + 1;
sgResults.FixedRows := 1;
for I := 1 to ResultSet.GetMetadata.GetColumnCount do
begin
//read out the proper value for the column
case ResultSet.GetMetadata.GetColumnType(I) of
stBoolean: if ResultSet.GetBoolean(I) then Value := 'True' else Value := 'False';
stByte: Value := IntToStr(ResultSet.GetByte(I));
stShort: Value := IntToStr(ResultSet.GetShort(I));
stInteger: Value := IntToStr(ResultSet.GetInt(I));
stLong: Value := IntToStr(ResultSet.GetLong(I));
stFloat: Value := FloatToStr(ResultSet.GetFloat(I));
stDouble: Value := FloatToStr(ResultSet.GetDouble(I));
stBigDecimal: Value := FloatToStr(ResultSet.GetBigDecimal(I));
stBytes, stBinaryStream: Value := ResultSet.GetBlob(I).GetString;
stDate: Value := DateToStr(ResultSet.GetDate(I));
stTime: Value := TimeToStr(ResultSet.GetTime(I));
stTimeStamp: Value := DateTimeToStr(ResultSet.GetTimeStamp(I));
stAsciiStream, stUnicodeStream: Value := ResultSet.GetBlob(I).GetString;
else
Value := ResultSet.GetString(I);
end;
if ResultSet.IsNull(I) then
Value := '';
sgResults.Cells[I - 1, sgResults.RowCount - 1] := Value;
end;
end;
end;
end;
procedure TfrmDBCDemo.sgResultsSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
if LastRowNr = AROw then
Exit;//Exit when the row nr has not changed
if Assigned(ResultSet) then
//Position the resultset to the selected row
ResultSet.MoveAbsolute(ARow);
InsertState := False;
LastRowNr := AROw;
end;
type
THackGrid = class(TStringGrid);
procedure TfrmDBCDemo.Button3Click(Sender: TObject);
begin
if Assigned(ResultSet) then
begin
if not InsertState then
begin
//Position the resultset to the selected row
ResultSet.MoveAbsolute(sgResults.Row);
LastRowNr := -1;
//Delete the selected row
ResultSet.DeleteRow;
end;
//Delete the selected row from the stringgrid
THackGrid(sgResults).DeleteRow(sgResults.Row);
end;
end;
{**
This method writes the modified data into the resultset.
Resultset also supports Updating field by name, for example UpdateStringByName
}
procedure TfrmDBCDemo.sgResultsSetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
begin
if Value = '' then
ResultSet.UpdateNull(ACol + 1)
else
case ResultSet.GetMetadata.GetColumnType(ACol + 1) of
stBoolean: ResultSet.UpdateBoolean(ACol + 1, UpperCase(Copy(Value, 1, 1)) = 'T');
stByte: ResultSet.UpdateByte(ACol + 1, StrToInt(Value));
stShort: ResultSet.UpdateShort(ACol + 1, StrToInt(Value));
stInteger: ResultSet.UpdateInt(ACol + 1, StrToInt(Value));
stLong: ResultSet.UpdateLong(ACol + 1, StrToInt(Value));
stFloat: ResultSet.UpdateFloat(ACol + 1, StrToFloat(Value));
stDouble: ResultSet.UpdateFloat(ACol + 1, StrToFloat(Value));
stBigDecimal: ResultSet.UpdateFloat(ACol + 1, StrToFloat(Value));
stBytes, stBinaryStream: ;
stDate: ResultSet.UpdateDate(ACol + 1, StrToDate(Value));
stTime: ResultSet.UpdateTime(ACol + 1, StrToTime(Value));
stTimeStamp: ResultSet.UpdateTimeStamp(ACol + 1, StrToDateTime(Value));
stAsciiStream, stUnicodeStream: ResultSet.UpdateString(ACol + 1, Value);
else
ResultSet.UpdateString(ACOl + 1, Value);
end;
end;
{**
Post the updates. If we are in insert status then insert otherwise update.
}
procedure TfrmDBCDemo.Button4Click(Sender: TObject);
begin
if Assigned(ResultSet) then
//Update the selected row
if InsertState then
ResultSet.InsertRow
else
ResultSet.UpdateRow;
end;
{**
Prepare for insert
}
procedure TfrmDBCDemo.Button5Click(Sender: TObject);
begin
sgResults.RowCount := sgResults.RowCount + 1;
sgResults.Row := sgResults.RowCount - 1;
sgResults.Col := 0;
ResultSet.MoveToInsertRow;
LastRowNr := sgResults.Row;
InsertState := True;
end;
end.