#1 2014-02-24 07:36:35

AOG
Member
Registered: 2014-02-24
Posts: 490

External database : connected or not.

Hello to all,

I am using mORMot (and ZEOS 7.1.3a) to store measurement data in an external MariaDB:

Model := CreateSampleModel;
Database := TSQLDBZEOSConnectionProperties.Create('mysql://server:3306','data','datauser','');
VirtualTableExternalRegisterAll(Model, Database);
Database.ForcedSchemaName:='data';
Client := TSQLRestClientDB.Create(Model,nil,SQLITE_MEMORY_DATABASE_NAME,TSQLRestServerDB,false,'');
Client.Server.CreateMissingTables;
....
....
Client.Add(...);         <--- no errors with server down
...
...
Client.TransactionBegin(...);         <--- no errors with server down
Client.BatchStart(...);         <--- no errors with server down
Client.BatchAdd(...);         <--- no errors with server down
Client.BatchSend(...);         <--- no errors with server down
Client.Commit;         <--- no errors with server down

All code above works ... tables are created ... data is saved !! Very good.

However, I do not know how to detect that the server is down ... does anybody know how to detect an external database server error when saving data ?

Real world:
Sometimes the connection is down at the moment the data is going to be saved.
Connection comes up again after a few seconds.
No further data is saved in the external database ... no errors occur in de code.

Greetings, Alfred.

Offline

#2 2014-02-24 08:34:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: External database : connected or not.

I do not understand well.
Here the Client is a TSQLRestClientDB, with its own RESTful server...
So which server are you talking about? The MySQL server?

We expect errors to be triggered when the external DB server is done.
Is there no exception raised at Zeos/ZDBC level?

I do not have MySQL here, only Oracle, FireBird or MS SQL databases, so I can't reproduce it with MySQL...

Offline

#3 2014-02-24 08:50:01

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: External database : connected or not.

Sorry about not being clear ... my bad ...

I was talking about the external mysql (mariadb) server being down !!
No errors are raised when that happens.
But more severe: when the mysql-server is up again, data update to the external mysql database is not resuming.

So once an external mysql server is down, the connection with this external mysql server is permanently broken.
My question: how to detect this and how to re-connect with the external server.

Thanks, Alfred.

Last edited by AOG (2014-02-24 08:52:33)

Offline

Board footer

Powered by FluxBB