Home » U++ Library support » U++ SQL » Application crashes when connected to MySQL, what am I doing wrong?
Application crashes when connected to MySQL, what am I doing wrong? [message #45113] |
Thu, 03 September 2015 17:07  |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi there,
I have been learning ultimatepp for a couple of weeks now, so I am kinda of a noob. My application communicates with a MySQL server. Usually I create a connection to the server each time I need data. I put each query in a separate method. The code goes like this:
void MyApplication::MyQuery1()
{
MySqlSession session;
if(session.Connect("Userfoobar", "secret", "mydb","192.168.1.1",3306))
{
SQL = session;
SqlSchema sch(MY_SQL);
All_Tables(sch);
SQL.ClearError();
try {
//Here's my query
int ritorno = Select(SqlSum(N_BOB))
.From(PEZZATURE)
.Where( COMM == ~dlgSceltaPezzature.strLav3A );
} catch(SqlExc &err) {
Cerr() << "ERROR: " << err << "\n";
ErrorOK("Problem retrieving data: " + session.GetLastError());
SetExitCode(1);
}
}
else {
ErrorOK("Connection to the db failed: " + session.GetLastError());
SetExitCode(1);
}
}
Note that the connection is not closed, but this has been worked well for me.
Today I experienced some unexpected crashes of my application. After some investigation, I noticed that the problem happens when pressing a specific button. This button executes some instructions including two different calls to two procedures similar to the one above, let's call them Myquey1 and Myquery2. If I comment out one of the two procedures, the application does not crash. Is not important which one I comment out, the important is that only one of the procedures is called, if I call both the application crashes. So, to me, the problem is not the procedure itself.
I thought that the problem was the fact that I do not close the connection, so I added the following line in each procedure:
if(session.IsOpen()) { session.Close(); }
but the problem is still there.
Could someone help me on this?
Regards,
Giorgio
|
|
|
Goto Forum:
Current Time: Tue Apr 29 15:07:01 CEST 2025
Total time taken to generate the page: 0.00309 seconds
|