How do I maintain connection in many classes accessing data from mysql database? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I maintain connection in many classes accessing data from mysql database?

9th Aug 2016, 4:40 AM
Patrick Wambugu
Patrick Wambugu - avatar
1 Answer
0
I had a job where i had to do this, and the best solution i found is to make an object, which is when created starts a connection. Instantiate it in your main class, then you can communicate with it from everywhere else.
22nd Aug 2016, 8:39 AM
Molnár Gábor
Molnár Gábor - avatar