I am writing a simple program in Eclipse CDT to connect to a MySQL Server hosted locally. I have ensured the server is running. The code I am trying to execute is the following:
The program crashes on running. While debugging I can see that the crash occurs while trying to establish the connection to the server. I have ensured that all required libraries have been added along with the required include files (I have images for the same but am unable to add them here). I am not sure what is it that I am doing wrong.
One of my doubts is the get_driver_instance() function used might from a different library, but adding sql:: or even sql::mysql:: in front of it gives undefined reference errors, even though the libraries have been added.
Here are items that have been included:
Header Files:
-I
1. "C:\Program Files\MySQL\MySQL Server 5.6\include"
2. "C:\Program Files\MySQL\Connector.C++ 1.1\include"
3. "C:\boost_1_66_0"
-include
1. "C:\Program Files\MySQL\Connector.C++ 1.1\include\mysql_connection.h" (added manually as there was an issue with the compiler finding it)
Libraries:
-L
1. "C:\Program Files\MySQL\MySQL Server 5.6\lib"
2. "C:\Program Files\MySQL\Connector.C++ 1.1\lib\opt"
Miscellaneous ( as they don't follow GCC naming conventions)
1. "C:\Program Files\MySQL\Connector.C++ 1.1\lib\opt\mysqlcppconn-static.lib"
2. "C:\Program Files\MySQL\Connector.C++ 1.1\lib\opt\mysqlcppconn.dll"
3. "C:\Program Files\MySQL\MySQL Server 5.6\lib\mysqlclient.lib"
4. "C:\Program Files\MySQL\MySQL Server 5.6\lib\libmysql.lib"
Before using driver,connection and statement you should check that they are not nullptr.
Also try to wrap the code into a try catch block to see if you get an error msg.