Hello! I just started to code database manager to my project and I got problem. System is crashing when I try to create my database manager object. I tried to debug program and I found somethgin really wierd.
I have included all the headers and linked libraries so code goes throught the compiler.
Here is how I define driver and connection pointers:
sql::Driver* mSqlDriver;
sql::Connection* mSqlConnection;
I am initing driver this way:
void DatabaseManager::init()
{
mSqlDriver = get_driver_instance();
}
After I use my database manager method "connectPlug" the program crashes.
Here is the whole method:
void DatabaseManager::connectPlug()
{
if(isConnected == false)
{
mSqlConnection = mSqlDriver->connect("tcp://127.0.0.1:3306", "root", "asdfgh");
//mSqlConnection->createDatabase("DB_createdfromCpp");
}
else
{
OutputManager::getSingletonPtr()->writeToRunLog("System is already plugged to database!");
}
}
Debugger gives error message "Unhandled exception at 0x7855b690 in FPS login server.exe: 0xC0000005: Access violation reading location 0xcccccccc."
If I don't use the connect method and I close my program by pressing X to close my window, the program freezes for a short time and then there comes an error message of windows. If I comment those lines where I am getting driver and connection, the program works well. So what could be the problem? I tried to watch
some examples and they are doing same way. I am using VC2008 and I've linked connector dynamically (I have all the DLLs at the run directory).
I have included all the headers and linked libraries so code goes throught the compiler.
Here is how I define driver and connection pointers:
sql::Driver* mSqlDriver;
sql::Connection* mSqlConnection;
I am initing driver this way:
void DatabaseManager::init()
{
mSqlDriver = get_driver_instance();
}
After I use my database manager method "connectPlug" the program crashes.
Here is the whole method:
void DatabaseManager::connectPlug()
{
if(isConnected == false)
{
mSqlConnection = mSqlDriver->connect("tcp://127.0.0.1:3306", "root", "asdfgh");
//mSqlConnection->createDatabase("DB_createdfromCpp");
}
else
{
OutputManager::getSingletonPtr()->writeToRunLog("System is already plugged to database!");
}
}
Debugger gives error message "Unhandled exception at 0x7855b690 in FPS login server.exe: 0xC0000005: Access violation reading location 0xcccccccc."
If I don't use the connect method and I close my program by pressing X to close my window, the program freezes for a short time and then there comes an error message of windows. If I comment those lines where I am getting driver and connection, the program works well. So what could be the problem? I tried to watch
some examples and they are doing same way. I am using VC2008 and I've linked connector dynamically (I have all the DLLs at the run directory).