Trubble in executing the cpp program...

I wrote a code like this.......

#include <iostream>
#include <stdio.h>
#include <mysql.h>
#include <string.h>
#include <stdlib.h>

using namespace std;

#include "Connection.h"

int main()
{
char *Host = (char *)"localhost";
char *Database =(char *)"sachin";
char *UserId =(char *)"root";
char *Password =NULL;
Result *result;
char *query;
Connection DbConnection(Host, Database, UserId, Password);
query="select * from the test"; // test is my database
result = DbConnection.Query(query); // perform the required database operation..

return 0;

}

Connection is the class & have connect function that just took the 4 arguments & establishes the connection to the mysql server ...Also Query is the function defined in connection class.

I m getting output as -
$g++ -c -I/usr/include/mysql Main.cpp
$ g++ -o Main Main.o -L/usr/lib/mysql -lmysqlclient
$./Main
terminate called after throwing an instance of 'char const*'
Aborted

I don't know why i m getting this output. I think it is related to the library.......

Can any one help me......

Either the constructor of Connection, or the Query() method throws an exception of type const char *. You can catch it, by enclosing the calls with try, and adding a catch block, like:

try {
    Connection DbConnection(Host, Database, UserId, Password);
    query="select * from the test"; // test is my database
    result = DbConnection.Query(query); // perform the required database operation..
}
catch (const char *errmsg)
{
    std::cerr << "error message from connection: " << errmsg << "\n";
    return 1;
}

May also be related to the fact that Host, Database, etc. should probably be declared as (const char *).

Well, I don't think so. Passing a "char*" to a function that expects "const char*" is perfectly legal. And if it wasn't, then the compiler would say so.

On the other hand, if the function would in fact require a "char*" it might expect the value to be writable, which is not the case for string literals. But I don't think that is the case here.

Also, the meaning of the message "terminate called after throwing an instance of 'char const*'" is pretty clear.