after program starts it's waiting for a MySQL server in a loop, every

second is trying to connect to local database, maximum is 5 tries
This commit is contained in:
Petr Hlozek 2014-11-03 21:22:49 +01:00
parent a851bf08d3
commit fe70b41e0c
5 changed files with 105 additions and 44 deletions

View File

@ -6,6 +6,8 @@ Legend:
1.8.3
- Rebuild membership statistic dialog was broken - fixed
# after program starts it's waiting for a MySQL server in a loop, every
second is trying to connect to local database, maximum is 5 tries
1.8.2
+ Select Modes in Preferences/New QSO for New QSO Form (Tom, DL7BJ)

View File

@ -510,8 +510,15 @@ begin
(MainCon as TMySQL51Connection).Port := StrToInt(port)
end
else begin
if fMySQLVersion = 5.5 then
begin
(MainCon as TMySQL55Connection).HostName := host;
(MainCon as TMySQL55Connection).Port := StrToInt(port)
end
else begin
(MainCon as TMySQL56Connection).HostName := host;
(MainCon as TMySQL56Connection).Port := StrToInt(port)
end
end;
MainCon.UserName := user;
MainCon.Password := pass;
@ -3333,6 +3340,8 @@ end;
procedure TdmData.StartMysqldProcess;
var
mysqld : String;
Connected : Boolean = False;
Tryies : Word = 0;
begin
mysqld := GetMysqldPath;
PrepareMysqlConfigFile;
@ -3342,9 +3351,57 @@ begin
' --socket='+fHomeDir+'database/sock'+
' --port=64000';
MySQLProcess.Execute;
if MainCon.Connected then
MainCon.Connected := False;
if fMySQLVersion < 5.5 then
begin
(MainCon as TMySQL51Connection).HostName := '127.0.0.1';
(MainCon as TMySQL51Connection).Port := 64000
end
else begin
if fMySQLVersion = 5.5 then
begin
(MainCon as TMySQL55Connection).HostName := '127.0.0.1';
(MainCon as TMySQL55Connection).Port := 64000
end
else begin
(MainCon as TMySQL56Connection).HostName := '127.0.0.1';
(MainCon as TMySQL56Connection).Port := 64000
end
end;
MainCon.DatabaseName := 'information_schema';
MainCon.UserName := 'cqrlog';
MainCon.Password := 'cqrlog';
sleep(2000)
while true do
begin
try try
Connected := True;
inc(Tryies);
MainCon.Connected := True
except
on E : Exception do
begin
if fDebugLevel>=1 then Writeln('Trying to connect to database');
Sleep(1000);
Connected := False;
if fDebugLevel>=1 then Writeln(E.Message);
if fDebugLevel>=1 then Writeln('Trying:',Tryies);
Continue
end
end
finally
MainCon.Connected := False
end;
if Connected or (Tryies>5) then break
end;
MainCon.DatabaseName := '';
if not Connected then
begin
Application.MessageBox('MySQL could not be started, please check if the MySQL server is installed properly','Error...',
mb_OK + mb_IconError)
end
end;
function TdmData.BandModFromFreq(freq : String;var mode,band : String) : Boolean;

View File

@ -9,7 +9,7 @@ object frmDBConnect: TfrmDBConnect
OnClose = FormClose
OnCreate = FormCreate
OnShow = FormShow
LCLVersion = '1.2.2.0'
LCLVersion = '1.2.4.0'
object grbLogin: TGroupBox
Left = 0
Height = 192
@ -17,13 +17,13 @@ object frmDBConnect: TfrmDBConnect
Width = 369
Align = alTop
Caption = ' MySQL server '
ClientHeight = 175
ClientHeight = 173
ClientWidth = 365
TabOrder = 0
Visible = False
object edtServer: TEdit
Left = 14
Height = 25
Height = 27
Top = 25
Width = 168
TabOrder = 0
@ -31,23 +31,23 @@ object frmDBConnect: TfrmDBConnect
end
object Label1: TLabel
Left = 14
Height = 15
Height = 17
Top = 9
Width = 72
Width = 87
Caption = 'Server name:'
ParentColor = False
end
object Label2: TLabel
Left = 218
Height = 15
Height = 17
Top = 9
Width = 28
Width = 34
Caption = 'Port:'
ParentColor = False
end
object edtPort: TEdit
Left = 218
Height = 25
Height = 27
Top = 25
Width = 80
TabOrder = 1
@ -55,30 +55,30 @@ object frmDBConnect: TfrmDBConnect
end
object Label3: TLabel
Left = 14
Height = 15
Height = 17
Top = 61
Width = 63
Width = 75
Caption = 'User name:'
ParentColor = False
end
object edtUser: TEdit
Left = 14
Height = 25
Height = 27
Top = 79
Width = 168
TabOrder = 2
end
object Label4: TLabel
Left = 218
Height = 15
Height = 17
Top = 61
Width = 56
Width = 70
Caption = 'Password:'
ParentColor = False
end
object edtPass: TEdit
Left = 218
Height = 25
Height = 27
Top = 79
Width = 132
EchoMode = emPassword
@ -87,9 +87,9 @@ object frmDBConnect: TfrmDBConnect
end
object chkSavePass: TCheckBox
Left = 18
Height = 18
Height = 24
Top = 114
Width = 93
Width = 111
Caption = 'Remeber me'
OnChange = chkSavePassChange
TabOrder = 4
@ -114,9 +114,9 @@ object frmDBConnect: TfrmDBConnect
end
object chkAutoConn: TCheckBox
Left = 206
Height = 18
Height = 24
Top = 114
Width = 98
Width = 115
Caption = 'Auto connect'
TabOrder = 7
end
@ -227,9 +227,9 @@ object frmDBConnect: TfrmDBConnect
TabOrder = 2
object chkAutoOpen: TCheckBox
Left = 8
Height = 18
Height = 24
Top = -1
Width = 227
Width = 267
Caption = 'Open recent log after program start'
TabOrder = 0
end
@ -247,9 +247,9 @@ object frmDBConnect: TfrmDBConnect
TabOrder = 2
object chkSaveToLocal: TCheckBox
Left = 12
Height = 18
Height = 24
Top = 2
Width = 188
Width = 227
Caption = 'Save log data to local machine'
OnClick = chkSaveToLocalClick
TabOrder = 0

View File

@ -4,31 +4,31 @@ LazarusResources.Add('TfrmDBConnect','FORMDATA',[
'TPF0'#13'TfrmDBConnect'#12'frmDBConnect'#4'Left'#3#243#1#6'Height'#3'('#2#3
+'Top'#3#194#0#5'Width'#3'q'#1#7'Caption'#6#19'Database connection'#12'Client'
+'Height'#3'('#2#11'ClientWidth'#3'q'#1#7'OnClose'#7#9'FormClose'#8'OnCreate'
+#7#10'FormCreate'#6'OnShow'#7#8'FormShow'#10'LCLVersion'#6#7'1.2.2.0'#0#9'TG'
+#7#10'FormCreate'#6'OnShow'#7#8'FormShow'#10'LCLVersion'#6#7'1.2.4.0'#0#9'TG'
+'roupBox'#8'grbLogin'#4'Left'#2#0#6'Height'#3#192#0#3'Top'#2#0#5'Width'#3'q'
+#1#5'Align'#7#5'alTop'#7'Caption'#6#14' MySQL server '#12'ClientHeight'#3#175
+#1#5'Align'#7#5'alTop'#7'Caption'#6#14' MySQL server '#12'ClientHeight'#3#173
+#0#11'ClientWidth'#3'm'#1#8'TabOrder'#2#0#7'Visible'#8#0#5'TEdit'#9'edtServe'
+'r'#4'Left'#2#14#6'Height'#2#25#3'Top'#2#25#5'Width'#3#168#0#8'TabOrder'#2#0
+#4'Text'#6#9'localhost'#0#0#6'TLabel'#6'Label1'#4'Left'#2#14#6'Height'#2#15#3
+'Top'#2#9#5'Width'#2'H'#7'Caption'#6#12'Server name:'#11'ParentColor'#8#0#0#6
+'TLabel'#6'Label2'#4'Left'#3#218#0#6'Height'#2#15#3'Top'#2#9#5'Width'#2#28#7
+'r'#4'Left'#2#14#6'Height'#2#27#3'Top'#2#25#5'Width'#3#168#0#8'TabOrder'#2#0
+#4'Text'#6#9'localhost'#0#0#6'TLabel'#6'Label1'#4'Left'#2#14#6'Height'#2#17#3
+'Top'#2#9#5'Width'#2'W'#7'Caption'#6#12'Server name:'#11'ParentColor'#8#0#0#6
+'TLabel'#6'Label2'#4'Left'#3#218#0#6'Height'#2#17#3'Top'#2#9#5'Width'#2'"'#7
+'Caption'#6#5'Port:'#11'ParentColor'#8#0#0#5'TEdit'#7'edtPort'#4'Left'#3#218
+#0#6'Height'#2#25#3'Top'#2#25#5'Width'#2'P'#8'TabOrder'#2#1#4'Text'#6#4'3306'
+#0#0#6'TLabel'#6'Label3'#4'Left'#2#14#6'Height'#2#15#3'Top'#2'='#5'Width'#2
+'?'#7'Caption'#6#10'User name:'#11'ParentColor'#8#0#0#5'TEdit'#7'edtUser'#4
+'Left'#2#14#6'Height'#2#25#3'Top'#2'O'#5'Width'#3#168#0#8'TabOrder'#2#2#0#0#6
+'TLabel'#6'Label4'#4'Left'#3#218#0#6'Height'#2#15#3'Top'#2'='#5'Width'#2'8'#7
+#0#6'Height'#2#27#3'Top'#2#25#5'Width'#2'P'#8'TabOrder'#2#1#4'Text'#6#4'3306'
+#0#0#6'TLabel'#6'Label3'#4'Left'#2#14#6'Height'#2#17#3'Top'#2'='#5'Width'#2
+'K'#7'Caption'#6#10'User name:'#11'ParentColor'#8#0#0#5'TEdit'#7'edtUser'#4
+'Left'#2#14#6'Height'#2#27#3'Top'#2'O'#5'Width'#3#168#0#8'TabOrder'#2#2#0#0#6
+'TLabel'#6'Label4'#4'Left'#3#218#0#6'Height'#2#17#3'Top'#2'='#5'Width'#2'F'#7
+'Caption'#6#9'Password:'#11'ParentColor'#8#0#0#5'TEdit'#7'edtPass'#4'Left'#3
+#218#0#6'Height'#2#25#3'Top'#2'O'#5'Width'#3#132#0#8'EchoMode'#7#10'emPasswo'
+#218#0#6'Height'#2#27#3'Top'#2'O'#5'Width'#3#132#0#8'EchoMode'#7#10'emPasswo'
+'rd'#12'PasswordChar'#6#1'*'#8'TabOrder'#2#3#0#0#9'TCheckBox'#11'chkSavePass'
+#4'Left'#2#18#6'Height'#2#18#3'Top'#2'r'#5'Width'#2']'#7'Caption'#6#10'Remeb'
+#4'Left'#2#18#6'Height'#2#24#3'Top'#2'r'#5'Width'#2'o'#7'Caption'#6#10'Remeb'
+'er me'#8'OnChange'#7#17'chkSavePassChange'#8'TabOrder'#2#4#0#0#7'TButton'#10
+'btnConnect'#4'Left'#2'*'#6'Height'#2#25#3'Top'#3#143#0#5'Width'#2'S'#7'Capt'
+'ion'#6#7'Connect'#7'OnClick'#7#15'btnConnectClick'#8'TabOrder'#2#5#0#0#7'TB'
+'utton'#13'btnDisconnect'#4'Left'#3#206#0#6'Height'#2#25#3'Top'#3#143#0#5'Wi'
+'dth'#2'W'#7'Caption'#6#10'Disconnect'#7'OnClick'#7#18'btnDisconnectClick'#8
+'TabOrder'#2#6#0#0#9'TCheckBox'#11'chkAutoConn'#4'Left'#3#206#0#6'Height'#2
+#18#3'Top'#2'r'#5'Width'#2'b'#7'Caption'#6#12'Auto connect'#8'TabOrder'#2#7#0
+#24#3'Top'#2'r'#5'Width'#2's'#7'Caption'#6#12'Auto connect'#8'TabOrder'#2#7#0
+#0#0#6'TPanel'#6'Panel1'#4'Left'#2#0#6'Height'#3'N'#1#3'Top'#3#218#0#5'Width'
+#3'q'#1#5'Align'#7#8'alClient'#10'BevelOuter'#7#6'bvNone'#7'Caption'#6#6'Pan'
+'el1'#12'ClientHeight'#3'N'#1#11'ClientWidth'#3'q'#1#8'TabOrder'#2#1#0#6'TPa'
@ -56,12 +56,12 @@ LazarusResources.Add('TfrmDBConnect','FORMDATA',[
+'sNative'#0#0#6'TPanel'#6'Panel4'#4'Left'#2#0#6'Height'#2#21#3'Top'#3'9'#1#5
+'Width'#3'q'#1#5'Align'#7#8'alBottom'#10'BevelOuter'#7#6'bvNone'#12'ClientHe'
+'ight'#2#21#11'ClientWidth'#3'q'#1#8'TabOrder'#2#2#0#9'TCheckBox'#11'chkAuto'
+'Open'#4'Left'#2#8#6'Height'#2#18#3'Top'#2#255#5'Width'#3#227#0#7'Caption'#6
+'Open'#4'Left'#2#8#6'Height'#2#24#3'Top'#2#255#5'Width'#3#11#1#7'Caption'#6
+'#Open recent log after program start'#8'TabOrder'#2#0#0#0#0#0#6'TPanel'#6'P'
+'anel3'#4'Left'#2#0#6'Height'#2#26#3'Top'#3#192#0#5'Width'#3'q'#1#5'Align'#7
+#5'alTop'#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#2#26#11'ClientWidth'#3
+'q'#1#8'TabOrder'#2#2#0#9'TCheckBox'#14'chkSaveToLocal'#4'Left'#2#12#6'Heigh'
+'t'#2#18#3'Top'#2#2#5'Width'#3#188#0#7'Caption'#6#30'Save log data to local '
+'t'#2#24#3'Top'#2#2#5'Width'#3#227#0#7'Caption'#6#30'Save log data to local '
+'machine'#7'OnClick'#7#19'chkSaveToLocalClick'#8'TabOrder'#2#0#0#0#0#6'TTime'
+'r'#14'tmrAutoConnect'#7'Enabled'#8#7'OnTimer'#7#19'tmrAutoConnectTimer'#4'l'
+'eft'#2'p'#3'top'#3#144#1#0#0#10'TPopupMenu'#8'popUtils'#4'left'#3'8'#1#3'to'

View File

@ -407,13 +407,15 @@ begin
end;
dbgrdLogs.DataSource := dmData.dsrLogList;
if StartMysql then
dmData.StartMysqldProcess;
LoadLogin;
if OpenFromMenu then
begin
UpdateGridFields;
EnableButtons
end
else begin
if StartMysql then
dmData.StartMysqldProcess
end;
dlgOpen.InitialDir := dmData.HomeDir;
dlgSave.InitialDir := dmData.HomeDir