MySQL Forums
Forum List  »  Connector/C++

weird issue
Posted by: David Marchbanks
Date: March 06, 2009 10:47PM

I'm trying to develop a program. For a while I thought I was just doing something horribly wrong. But I've tried re-doing everything a couple times now. Examples inside the connector work but mine don't, and I'm getting a bit frustrated.

I'm using Visual Studio Express 2009 and I have everything linked and I receive NO compile errors. However, when I try to connect, I get strange characters, as well as strange characters when I query the mysql driver.

Here is the source of my current test enviroment.

#include <mysql_connection.h>
#include <mysql_driver.h>
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>


#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
try {
sql::mysql::MySQL_Driver *driver=sql::mysql::get_mysql_driver_instance();

cout << "# " << driver->getName() << ", version ";
cout << driver->getMajorVersion() << "." << driver->getMinorVersion();
cout << "." << driver->getPatchVersion() << endl;

sql::Driver *driver2=::get_driver_instance();
cout << "# " << driver2->getName() << ", version ";
cout << driver2->getMajorVersion() << "." << driver2->getMinorVersion();
cout << "." << driver2->getPatchVersion() << endl;

cout << "Trying to connect locally..." << endl;
sql::Connection *con=driver->connect("tcp://localhost","root","password");

}
catch(sql::SQLException &e) {
cout << e.what() << endl;
cout << e.getSQLState() << endl;
}
return 0;
}

/////////////////////////////////////////////////////

Here is the output

# ▲ ▼ ☺ , version 1.0.3
# ▲ ▼ ☺ , version 1.0.3

////////////////////////////////////////////////////

What am I doing wrong?

Options: ReplyQuote


Subject
Views
Written By
Posted
weird issue
2793
March 06, 2009 10:47PM


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.