views:

136

answers:

1

We are using swi-prolog to run our testcases. Whenever the test starts, I am opening the connection to MYSQL database and storing the Name of the Test hat is being done and then closing the DB. These tests run for about 2 days continuously. After the tests are done, the results basically gets stored in folder in the server. There is a predicate in another prolog file that is called to update the results to the MYSQL database. The code is simple, I use odbc library and just call odbc_* predicates to connect and update the mysql by issuing direct queries.

The actual problem is :

  1. If I try to call the Predicate from the same Prolog window, where the test just got completed, I get an error as updating to the DB server. Although I do not get any error in the connection. If I close the session of that prolog with halt and closing all the open prolog windows , then open an other complete new instance of Prolog and run the predicate the update goes well.

I have a feeling that there is some connection reference to the MySQL DB in Prolog database. Is there any way to clear the database in prolog so that I can run the same predicate without closing any existing prolog windows?

Any ideas appreciated.

Thanks.

+1  A: 

If you open the connection, than do a long processing, MySQL can drop the connection in between after a certain timeout (that I believe can do configured in my.cnf).

EDIT: swi-prolog has an odbc_disconnect that can be used to explicitly close the connection after using it and an "aliasing" mode that can be used to obtain a previously opened connection when using odbc_open. In you case you can try either closing the connection after using it. You should also avoid using an alias when opening.

baol
I know that. But I am opening the connection again in the update predicate. But I am not sure why the update the not taking place.
JPro
It seems you've changed your question partially confirming my suspects of a timing out connection. Do you use odbc_disconnect? Otherwise you should perhaps try to use odbc_current_connection to check your connections. You should also check the documentation of odbc_connect regarding the alias name of the connection and the "multiple" opening modes.
baol