Checking a remote server is connected

Is their a preferred or simple method of checking with a remote tcp/ip database is connected from a method?

There doesnt seem to be a function in the database manager, but just thought that someone may have a simple way to do it?

The purpose is to test whether a remote server i am using to bring information into my local solution with sybase is up and running prior to performing a number of queries?

Thanks in advance

David

We have a client traveling around S.America who often has very poor connections back to the Server in Europe.

In order to re-assure him that he is still connected we have a cron job that every 10 secs does an application.getServerTimeStamp() and after formatting displays it in the Status Text area with application.setStatusText( vDate)

Maybe a bit crude but quite effective - as long as the Server time is updating he must be connected.

HTH

Hi David,

I wonder whether the ServoyException node in the method editor tree may hold the answer to this :)

If you run a test query on the remote database then it will return an error of some description if the database cannot be reached.

So you should be able to pass this error through to an error handler method and do something as a consequence of failure

Cheers
Harry

Thanks for that Harry,

yes that worked. I also found doing a simple Rawsql query selecting one field on the first record in my customer file (WHICH NEVER CHANGES) also returns a true or false.

Servoy Offline is really very useful. I have managed to create a standalone application with the sybase backend and using a combination of the database tools and the RawSQl pluing have managed to allow users to download records to work on offline and then sync them back to the main server, which runs on MYSQL.

Its a lot less complicated then the Mobilink, although its not true replication. it seems to do the job well.

Thanks to you and Graham.

David

Hi David,

could you please tell us more how you achieved this?
Are you using uuid’s or PK’s for syncing?

I think more developers are interested in this.
Maybe a topic on http://www.servoymagazine.com ? :wink:

HJK,

What i have done is created essentially a mirror of my key MYSQL tables using the copy table function in servoy, putting them into SYBASE.

My application is basically for doctors to write reports. While there are some one to many relationships within a report, i am lucky in that the real output is collated into each main record as an HTML preview and then a pdf blob field.

The problem i wished to solve was that if a doctor goes to another location he is concerned that his appointments and the use of the software is wholly dependant on Internet Access. When you have 15 reports to do in a single day, it is quite worrying to think you may have to revert to paper notes and then spend hours doing the reports at home.

So the solution is really split into three phases:

  1. First login, downloads the customer record, along from the remote table just for that doctor. it then downloads other related information such as only his clients and his consulting venues. (This is then repeated if he wants to update anything, by simply deleting all these records and then downloading them again.

  2. The i have used a simple query to pull all appointments for X days in advance down to the local database. Again the generation of keys is switched off.

  3. Once a report is completed, I simply flag it for upload and then using the RAWSQL query write the fields back to the remote database.

Because i dont generate any primary keys for my Customer, Consulting Addresses or Appointments locally then moving the data back is easy.

The downside of this is it is not true syncronisation, in that it has to be made clear that the local solution is essentially a throw away one. This is actually quite useful because updating servoy offline has also been a topic on discussion boards and this means that it can be replaced at any stage with an update. So any data such as individual injuries which exist in sub tables from the main one doesnt get synced back because the primary keys are generated locally, but what matters is the text of those injuries is within the main preview section that goes back up to the remote database.

It seems to do the job. Just getting into things like security etc now as you will see from the Offline discussion board.

David