Answer the question, please!
I use ZEOSDBO-6.6.0-beta and the library libmysqld41.dll.
Is it possible to change “datadir” for MySQL Embedded Server in my program?
I tried to pass the new value in ZConnection – it didn’t work.
I tried to destroy the TZConnection object and create it with new parameters – but with no results. Anyway “datadir” has the first (initial) value.
Change “datadir” for MySQL Embedded Server
Moderators: gto, cipto_kh, EgonHugeist
I read that example several times. As I have written everything goes well until I change the variable “datadir “.
I’m not a programmer, so correct me please.
There are two identical databases 'pr1' и 'pr2' in folders 'C:\Data' и 'C:\Temp\Data'.
This is my code:
private
FConnection: TZConnection;
public
property Connection: TZConnection read FConnection write FConnection;
......
procedure TForm1.CreateOurConnection(strDb,strDataDir:string);
var
tmpStringList: TStrings;
begin
Connection := TZConnection.Create(Self);
Connection.Protocol := 'mysqld-4.1';
Connection.HostName := '';
Connection.Database := strDb;
Connection.User := '';
Connection.Password := '';
Connection.Port:=0;
tmpStringList := TStringList.Create;
try
with tmpStringList do begin
Add('compress=yes');
Add('dbless=no');
Add('useresult=no');
Add('timeout=30');
Add('ServerArgument1=--basedir=./');
Add('ServerArgument2=--datadir='+strDataDir);
Add('ServerArgument3=--character-sets-dir=./share/charsets');
Add('ServerArgument4=--language=./share/english');
Add('ServerArgument5=--skip-innodb');
Add('ServerArgument6=--key_buffer_size=32M');
end;
Connection.Properties.Assign(tmpStringList);
finally
tmpStringList.free;
end;
end;
procedure TForm1.DestroyOurConnection;
begin
Connection.Connected := False;
Connection.Destroy;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
CreateOurConnection('pr1', 'C:/Data');
Connection.Connected := True;
DestroyOurConnection;
CreateOurConnection('pr2', 'C:/Temp/Data');
Connection.Connected := True;
end;
Appear the mistake “SQL Error: Unknown database ‘pr2’”.
If to change the variable of Database ‘pr2’ on ‘pr1’:
CreateOurConnection('pr1', 'C:/Temp/Data');
connection will be fixed without any mistake.
What is the mistake?
Thank you!
I’m not a programmer, so correct me please.
There are two identical databases 'pr1' и 'pr2' in folders 'C:\Data' и 'C:\Temp\Data'.
This is my code:
private
FConnection: TZConnection;
public
property Connection: TZConnection read FConnection write FConnection;
......
procedure TForm1.CreateOurConnection(strDb,strDataDir:string);
var
tmpStringList: TStrings;
begin
Connection := TZConnection.Create(Self);
Connection.Protocol := 'mysqld-4.1';
Connection.HostName := '';
Connection.Database := strDb;
Connection.User := '';
Connection.Password := '';
Connection.Port:=0;
tmpStringList := TStringList.Create;
try
with tmpStringList do begin
Add('compress=yes');
Add('dbless=no');
Add('useresult=no');
Add('timeout=30');
Add('ServerArgument1=--basedir=./');
Add('ServerArgument2=--datadir='+strDataDir);
Add('ServerArgument3=--character-sets-dir=./share/charsets');
Add('ServerArgument4=--language=./share/english');
Add('ServerArgument5=--skip-innodb');
Add('ServerArgument6=--key_buffer_size=32M');
end;
Connection.Properties.Assign(tmpStringList);
finally
tmpStringList.free;
end;
end;
procedure TForm1.DestroyOurConnection;
begin
Connection.Connected := False;
Connection.Destroy;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
CreateOurConnection('pr1', 'C:/Data');
Connection.Connected := True;
DestroyOurConnection;
CreateOurConnection('pr2', 'C:/Temp/Data');
Connection.Connected := True;
end;
Appear the mistake “SQL Error: Unknown database ‘pr2’”.
If to change the variable of Database ‘pr2’ on ‘pr1’:
CreateOurConnection('pr1', 'C:/Temp/Data');
connection will be fixed without any mistake.
What is the mistake?
Thank you!
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
I think the problem is that you are trying to use two embedded servers... Basicly it means you need 2 dll's being loaded as far as I know.
User tohenk has the same problem and provided a patch that can handle this.
I'll attach his SVN patch file to this reply. It can help you for now, I hope. This feature will probably not be implemented in 6.6 version. Remember, the only one who can help you with this patch is tohenk.
An other workaround : copy the embedded dll as libmysql41 and use 2 different protocols (mysql-4.1 and mysqld4.1). This is not a beautifull solution, but it should work unless you also need a regular server connection or more than 2 embedded servers.
Mark
User tohenk has the same problem and provided a patch that can handle this.
I'll attach his SVN patch file to this reply. It can help you for now, I hope. This feature will probably not be implemented in 6.6 version. Remember, the only one who can help you with this patch is tohenk.
An other workaround : copy the embedded dll as libmysql41 and use 2 different protocols (mysql-4.1 and mysqld4.1). This is not a beautifull solution, but it should work unless you also need a regular server connection or more than 2 embedded servers.
Mark
You do not have the required permissions to view the files attached to this post.