bool insertIntoTable(string database,string table, string query){ cout<<"Entering insertIntoTable"<<endl; bool allIsWell=false; try { sql::Driver *driver; sql::Connection *con; sql::Statement *stmt; driver = get_driver_instance(); con = driver->connect("tcp://127.0.0.1:3306", "root", "root"); con->setSchema(database); stmt = con->createStatement(); stmt->executeQuery("insert into trade values (100)"); delete stmt; delete con; allIsWell=true; } catch (sql::SQLException &e) { cout << "# ERR: SQLException in " << __FILE__<<endl; cout << "# ERR: " << e.what()<<endl; cout << " (MySQL error code: " << e.getErrorCode()<<endl; cout << ", SQLState: " << e.getSQLState() << " )" << endl; } cout<<"Exiting insertIntoTable"<<endl; return allIsWell; }
This programs inserts successfully into table but gives exception : # ERR: SQLException in DBManager.cpp # ERR: (MySQL error code: 0 SQLState: 00000 )
executeQuery
execute
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)