@@ -17,6 +17,7 @@ void sql_unlocked(const std::string& DeleteName)
17
17
{
18
18
std::cerr << " SQL Exception: in sql_unlocked() function" << e.what () << std::endl;
19
19
}
20
+ con->close ();
20
21
delete stmt;
21
22
delete con;
22
23
}
@@ -36,6 +37,10 @@ int sql_findexist(const std::string& receiver)
36
37
if (receiver == resultSet->getString (" username" ))
37
38
return 1 ;
38
39
}
40
+ con->close ();
41
+ delete con;
42
+ delete readdatament;
43
+ delete resultSet;
39
44
return 0 ;
40
45
}
41
46
int lockcheck (const std::string& filename)
@@ -56,6 +61,12 @@ int lockcheck(const std::string& filename)
56
61
sql::PreparedStatement *changestatement = con->prepareStatement (changestate);
57
62
changestatement->setString (1 , filename);
58
63
changestatement->executeUpdate ();
64
+
65
+ con->close ();
66
+ delete con;
67
+ delete readdatament;
68
+ delete resultSet;
69
+ delete changestatement;
59
70
return 0 ;
60
71
}
61
72
void process (sql::PreparedStatement *readDatament, std::vector<std::string> s, sql::Connection *con)
@@ -79,6 +90,7 @@ void process(sql::PreparedStatement *readDatament, std::vector<std::string> s, s
79
90
updateStatement->setString (1 , friendlist);
80
91
updateStatement->setString (2 , s[i]);
81
92
updateStatement->execute ();
93
+ delete resultSet;
82
94
}
83
95
}
84
96
@@ -94,6 +106,10 @@ void sql_delete_operation(const std::string& sender, const std::string& receiver
94
106
95
107
sql::PreparedStatement *readDatament = con->prepareStatement (readdata);
96
108
process (readDatament, s, con);
109
+
110
+ con->close ();
111
+ delete con;
112
+ delete readDatament;
97
113
}
98
114
99
115
void sql_process_request (const std::string& sender, const std::string& receiver, const std::string& attitude)
@@ -167,6 +183,8 @@ void sql_process_request(const std::string& sender, const std::string& receiver,
167
183
}
168
184
delete[] RS;
169
185
}
186
+
187
+ con->close ();
170
188
delete updateStatement;
171
189
delete resultSet;
172
190
delete readDatament;
@@ -213,6 +231,7 @@ void sql_addrequest(const std::string& sender, const std::string& receiver)
213
231
delete updateStatement;
214
232
}
215
233
234
+ con->close ();
216
235
delete resultSet;
217
236
delete readDatament;
218
237
delete tool;
@@ -236,6 +255,7 @@ void sql_addhistory(const std::string& sender, const std::string& receiver, cons
236
255
insertData->setString (5 , receiver);
237
256
insertData->executeUpdate ();
238
257
258
+ con->close ();
239
259
delete insertData;
240
260
delete con;
241
261
}
@@ -263,6 +283,7 @@ void sql_add(const std::string& username, const std::string& passwd, int avatar)
263
283
ptool->setString (4 , " FlypenTeam" );
264
284
ptool->executeUpdate ();
265
285
286
+ con->close ();
266
287
delete ptool;
267
288
delete tool;
268
289
delete con;
@@ -310,6 +331,7 @@ Json::Value get_my_info(const std::string& me)
310
331
{
311
332
info[" avatar" ] = res->getInt (" avatar" );
312
333
}
334
+ delete res;
313
335
return info;
314
336
};
315
337
@@ -341,8 +363,13 @@ Json::Value get_my_info(const std::string& me)
341
363
std::string userJson = Json::writeString (builder, user);
342
364
343
365
json[me] = user;
366
+
367
+ delete prepStmt;
368
+ delete res;
344
369
}
345
370
}
371
+ con->close ();
372
+ delete con;
346
373
}
347
374
catch (sql::SQLException &e)
348
375
{
@@ -380,13 +407,14 @@ bool sql_check(const std::string& user, const std::string& passwd)
380
407
result = false ;
381
408
}
382
409
410
+ con->close ();
383
411
delete res;
384
412
delete prepStmt;
385
413
delete con;
386
414
}
387
415
catch (sql::SQLException &e)
388
416
{
389
- std::cerr << " SQL Exception: " << e.what () << std::endl;
417
+ // std::cerr << "SQL Exception: " << e.what() << std::endl;
390
418
}
391
419
392
420
// std::cout << result << std::endl;
@@ -483,6 +511,7 @@ Json::Value sql_find_my_msg(const std::string& me, const std::string& connect_ty
483
511
for (auto &x : sender_messages)
484
512
result[x.first ] = x.second ;
485
513
514
+ con->close ();
486
515
delete res;
487
516
delete prepStmt;
488
517
delete con;
@@ -505,5 +534,6 @@ void set_avatar(const std::string& person, int avatar)
505
534
updateStatement->setInt (1 , avatar);
506
535
updateStatement->setString (2 , person);
507
536
updateStatement->execute ();
537
+ con->close ();
508
538
delete con;
509
539
}
0 commit comments