Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

Error setSchema (no replies)

$
0
0
Hey all.

I try to find a solution for this error over many houres but there is no solution i think.

At the first here the error:

# ERR: SQLException in /home/Sick/Documents/cpp projects/Oktopussy/EventServer/main.cpp(main) on line 120
# ERR: MySQL_Connection::prepareStatement(const sql::SQLString& sql, int* columnIndexes) (MySQL error code: 0, SQLState: )

this error appears at con->setSchema("W_GAME");

And here the code

try
{
printf("declare variables\n");
sql::Driver *driver;
sql::Connection *con;
sql::ResultSet *r_set;
sql::Statement *st_mnt;
sql::PreparedStatement *pstmt;

driver = get_driver_instance();

//Connect to server
con = driver->connect("tcp://127.0.0.1:3306", "user", "pw");
printf("Connect to Server\n");

//select db
con->setSchema("W_GAME");
printf("Select db\n");

pstmt = con->prepareStatement("INSERT INTO player (name,points,kills,games) VALUES (?, ?, ?, 0) ON DUPLICATE KEY UPDATE points=points+?,kills=kills+?,games=games+1 WHERE name=?");
printf("Create Statement\n");

pstmt->setString(1, name);
pstmt->setInt(2, points);
pstmt->setInt(3, kills);
pstmt->setInt(4, points);
pstmt->setInt(5, kills);
pstmt->setString(6, name);

pstmt->execute();

con->close();

delete pstmt;
delete con;
delete st_mnt;
delete r_set;


printf("SQL Executed!\n");
} catch (sql::SQLException &e) {

cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << " )" << endl;

}

I tryed so many but nothing helps.

Thanks in front of

MfG Sick^

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>