Test if database is online

Questions and answers regarding general SQL and backend databases

Test if database is online

Postby dpriddle1331311432 » Wed Apr 11, 2012 7:28 pm

This question has probably already been answered somewhere, but I'm having trouble finding the answer.

I want to be able to test if a given database server is online.

Using databaseManager.getServerNames() I'm able to generate a list of all the databases that were enabled at startup. But how, without doing some kind of actual query on the database, can I determine if the database is online?

Or perhaps I should ask is there an inexpensive querry I could perform that would tell me if a given database is online?

Ideally, this should work for both traditional databases such as mysql and postgresql as well as others such as MongoDB and FileMaker.
Dave Riddle
Servoy Developer
McGilly Information Systems
dpriddle1331311432
 
Posts: 2
Joined: Fri Mar 09, 2012 6:43 pm

Re: Test if database is online

Postby jdbruijn » Thu Apr 12, 2012 10:48 am

My guess would be to use the maintenance plugin (see isValid() for JSServer), I never used this but it seems to me a check for an active server. Or you could run a simple query on the server (i.e. select 1 from table).
The last option would recieve a time-out if the server is offline, so you would have to wait until that time-out expires and I think that is depending on the db settings.
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 2 guests