Click here to Skip to main content
15,741,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am new in C++ 98 with QT-4 in netbeans 8.1 . I am trying to make data base connection using this code.

#include "newForm.h"
#include <cstdlib>
#include <stdio.h>

#include <string.h>
#include <string>

using namespace std;
#include <stdlib.h>
#include <iostream>
#include <fstream>

#include <sstream>
#include <istream>
#include <stdexcept>
#include <istream>
#include <qimage>
#include <qpixmap>

#include <mysql mysql.h="">
#include <cppconn driver.h="">
#include <cppconn exception.h="">
#include <cppconn connection.h="">
#include <cppconn resultset.h="">
#include <cppconn statement.h="">
#include <cppconn prepared_statement.h="">
#include <qgraphicspixmapitem>

using namespace sql;     // <---- add here

sql::Driver * driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
sql::PreparedStatement *prep_stmt;

int counter = 1;

newForm::newForm() {

    driver = get_driver_instance();
    con = driver->connect("localhost","","");
    con->setSchema("BitmapIMGSchema");  -->error

The program is crashing at this line

con->setSchema("BitmapIMGSchema");  -->error

With error

terminate called after throwing an instance of 'sql:InvalidArgumantException'

what(): The connection is in autoCommit mode.

What I have tried:

I have searched that error on internet but did not give solution.
Updated 16-Nov-22 20:22pm

1 solution

Auto commit mode means that as soon as a statement is executed, Commit is called on the connection.

At a guess - and I have no access to your system for testing - the setSchema call throwing an error probably means that the DB name BitmapIMGSchema is causing the problem.

Id start looking at your DB's carefully with your DB management software and see exactly what you have to play with.

Sorry, but we can't do anything specific to help you.
Share this answer
CPallini 17-Nov-22 7:43am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900