MySQL Forums
Forum List  »  Connector/C++

Unhandled exception at 0x78144500 in REPORTINGP.exe: 0xC0000005: Access violation reading location 0xcccccccc.
Posted by: Jakub Martinovic
Date: June 19, 2009 03:51AM

Hi,
I am creating small console in c++ and I have got the message during debugging:
Unhandled exception at 0x78144500 in REPORTINGP.exe: 0xC0000005: Access violation reading location 0xcccccccc.

which was debugged as problem of - con 0xcccccccc sql::Connection *

>>>> __vfptr CXX0030: Error: expression cannot be evaluated

I am attaching the code:

// Basic Headder
#include <stdafx.h>

/* Standard C++ headers */
#include <iostream>
#include <sstream>
#include <memory>
#include <string>
#include <stdexcept>

/* MySQL Connector/C++ specific headers */
#include <connection.h>
#include <driver.h>
#include <statement.h>
#include <prepared_statement.h>
#include <resultset.h>
#include <metadata.h>
#include <resultset_metadata.h>
#include <exception.h>
#include <warning.h>


#define DBHOST "tcp://xxx.xxx.xxx.xxx:xxxx"
#define USER "root"
#define PASSWORD "xxx"
#define DATABASE "report"


using namespace std;
using namespace sql;


// global variables definition
char config[5][50];
char line[50];

// Time getting function
/*void v_getTime()
{
time_t rawtime;
struct tm * timeinfo;

time_t ( &rawtime );
timeinfo = localtime ( &rawtime );
cout << "Status:\t Time: " << asctime (timeinfo);
return;
}*/



/*
void readconfigFile()
{
int i;
i=0;
FILE *fp;

fp=fopen("config.txt", "r");
if(fp==NULL) {
cout << "Error Status : File not found!" << endl;
cout << "-----------------------------------------------------" << endl;
cout << "Please insert temporary configuration data manually" << endl;
cout << "Host:";
cin >> config[0];
cout << "Login:";
cin >> config[1];
cout << "Password:";
cin >> config[2];
cout << "Database:";
cin >> config[2];
cin.get();
}
else {
cout << "Status: Reading configuration data from config.txt" << endl;
while(!feof(fp)) {
fscanf(fp,"%s",&line);
//config=line;
//cout << config <<endl;
i++;
}
fclose(fp);
}

return;
}
*/



/* Mysql status

------------------------------------------------------------------------------
Connect to the DB
------------------------------------------------------------------------------
*/
void MySQL_EX(){

Driver *driver;
Connection *con;
Statement *stmt;

string url = DBHOST;
const string user = USER;
const string password = PASSWORD;
const string database = DATABASE;

//try {

driver = get_driver_instance();
con = driver -> connect(url, user, password);
stmt = con->createStatement();
/* stmt->execute("USE test");
stmt->execute("DROP TABLE IF EXISTS test");
stmt->execute("CREATE TABLE test(id INT, label CHAR(1))");
stmt->execute("INSERT INTO test(id, label) VALUES (1, 'a')");*/


delete stmt;
con -> close();
delete con;

//} catch (SQLException &e) {
// cout << "Error" << endl;
//
//
//
//}

}


int main (int argc, char *argv[])
{

/*
------------------------------------------------------------------------------
Definition of variables
- mysql connection parameters
------------------------------------------------------------------------------
*/
// mysql vars

// System status - Primary status
cout << "*****************************************************" << endl;
cout << "Status:\t System mt4_DataBase reporting tool started" << endl;
//v_getTime();
//readconfigFile();
cout << "*****************************************************" << endl;
MySQL_EX();





// In a case of undefined error will occure the service will stop
cout << "Services have been interupted, because of undefined error." << endl;
cout << "Press ENTER to turn of the services and start them manually again..." << endl;
getchar();
return 0;
}



Some idea of solution?

I am looking forward to hearing from you..

Regards,
Jakub M.H.



Edited 1 time(s). Last edit at 06/19/2009 09:51AM by Jakub Martinovic.

Options: ReplyQuote


Subject
Views
Written By
Posted
Unhandled exception at 0x78144500 in REPORTINGP.exe: 0xC0000005: Access violation reading location 0xcccccccc.
8642
June 19, 2009 03:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.