Detecting Mysql Problems


cycler

Recommended Posts

We have a logging system that automatically records oven temperatures into a MySql db via export sets. The system has worked fine for a few years, but we are now occasionally getting socket errors that stop the export sets working. Until the IT guys can sort out the socket problem, I have tried using try catch() to detect the problem, but this does not work with beginexport(). 

 

My next idea is to attempt a db.Open() (and close) in a loop every few minutes as a means of detecting this problem. Can you suggest an easier method?

Link to comment
Share on other sites

Export sets run in a separate thread so you can't catch their errors except using OnAlert.  Doing db.Open() is a good way to check for problems, though you'll probably want to run a simple query as well, maybe:

 

select fieldname from tablename limit 1;

 

I'm not sure if Open() will fail if the socket is a problem.  The OS may cache the connection.  But doing an actually query will force the issue.

 

If you really want to do good error handling on the database you should move the export set functionallity into script using the db. functions, specifically db.execute() and build up the INSERT INTO command yourself.  Then you can catch any error right away.  You'd also gain flexibility in how the data goes into the database.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.