Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Echo - Multiple Types of Databases

 Post Reply Post Reply
Author
Bishop Greg View Drop Down
New Member
New Member
Avatar

Joined: 17 Feb 2019
Posts: 9
Post Options Post Options   Quote Bishop Greg Quote  Post ReplyReply Direct Link To This Post Topic: Echo - Multiple Types of Databases
    Posted: 27 Feb 2020 at 3:35am
Is there a sample project available that uses two different databases?  I'm thinking something like the Echo client/server example in EchoDemo_XDataServer.groupproj, but with MySQL on the server and SQLite on the clients?
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2889
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 27 Feb 2020 at 8:47pm
You can use multiple types of databases. All you have to do is configure the connection (in TAureliusConnection) to the database you want. 
Back to Top
Bishop Greg View Drop Down
New Member
New Member
Avatar

Joined: 17 Feb 2019
Posts: 9
Post Options Post Options   Quote Bishop Greg Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2020 at 4:17am
I seem to have the server working correctly, as it will create the echo tables and class tables in a blank MySQL database.

But, when the the EchoTestDemo application attempts to push data to the server, the following error message is presented:  "Data Type Conversion is Not Supported".  Please also reference a screenshot at:

https://1drv.ms/u/s!Aj_mqyr_6rLysYsEfBZ9c-zF2gB-yw?e=hmh0yd

I assume that there is some conversion occurring between SQLite and MySQL.

I've identified one possible section of code in the EchoTestDemo.exe application that may need updating to be able to use MySQL on the server (in RemoteModule.pas):

function TdmEcho.CreateConnection(const ADBName: string): IDBConnection;
var
  FileName: string;
begin
  // Refers to a SQLite database in the same directory as the executable,
  // with the name given by "DBName"
  FileName := TPath.ChangeExtension(ADBName, '.db');
  FileName := TPath.Combine(TPath.GetDirectoryName(ParamStr(0)), FileName);
  Result := TSQLiteNativeConnectionAdapter.Create(FileName);
end;

This points to a local SQLite database to create a connection.  I assume I would need to change this to reference the MySQL database instead, but I'm not sure what to use for connection code.  Or, do I need to reference the Echo server?

I'd appreciate any guidance.




Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2889
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2020 at 2:20pm
That piece of code creates the SQLite database. Aurelius doesn't create other databases. You have to create the MySQL database, and in CreateConnection you just return the connection to the created database.
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2889
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2020 at 10:48pm
The error you are getting is unfortunately a specific error of Aurelius, that happens when:
1. You use MySQL;
2. You use Blobs using Unicode encoding;
3. You are using a recent MySQL 8 client library (libmysql.dll)
4. Yo use FireDac.

Unfortunately you hit such condition. Nevertheless we will be releasing a fix in the next Aurelius update.
To workaround it now, you can just change one of the above conditions: Either try to use an older MySQL client library (5.x, for example), or test with a different database, or use a component different than FireDac. You can't change the Unicode Blob because that's what is mapped in Echo.
Back to Top
Maffessoni Cristiano View Drop Down
New Member
New Member
Avatar

Joined: 29 Jan 2020
Posts: 4
Post Options Post Options   Quote Maffessoni Cristiano Quote  Post ReplyReply Direct Link To This Post Posted: 03 Mar 2020 at 7:49am
Following parameters may work at MySQL connection. 

      FDConnection.LoginPrompt := False;
      FDConnection.Params.Values['Database'] := '<mydatabase>';
      FDConnection.Params.Values['DriverID'] := 'MySQL';
      FDConnection.Params.Values['User_Name'] := username; ;
      FDConnection.Params.Values['Password'] := password; ;
      FDConnection.Params.Values['Server'] := address;
      FDConnection.Params.Values['StringFormat'] := 'Ansi';  // <<<<<<<<
      FDConnection.Params.Values['CharacterSet'] := 'utf8';  // <<<<<<<<
      FDConnection.Connected := True;
Back to Top
Bishop Greg View Drop Down
New Member
New Member
Avatar

Joined: 17 Feb 2019
Posts: 9
Post Options Post Options   Quote Bishop Greg Quote  Post ReplyReply Direct Link To This Post Posted: 04 Mar 2020 at 5:23pm
I have this working now under the four conditions Wagner listed and with Maffessoni's suggestion of these two lines added:

      FDConnection.Params.Values['StringFormat'] := 'Ansi';  // <<<<<<<<
      FDConnection.Params.Values['CharacterSet'] := 'utf8';  // <<<<<<<<

Many thanks!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down