I use FreeBsd 8.0 amd64 and this package mysql-client-5.1.61, mysql-connector-c++-1.1.0, mysql-server-5.1.61 and gcc 4.2.1
I have this code
string vU="demo",vP="1234";
Driver * vDriver = get_driver_instance();
auto_ptr< Connection > vCon(vDriver->connect(getHost(),getUser() , getPassword() ));
vCon->setSchema(getDB());
auto_ptr<Statement > vStmt(vCon->createStatement());
auto_ptr<PreparedStatement > pstmt;
auto_ptr<ResultSet> res;
vStmt->execute("DROP PROCEDURE IF EXISTS fLoghin");
vStmt->execute("CREATE PROCEDURE fLoghin(in pUser varchar(200),in pPass varchar(200),out pUId int,out pTip int,out pEId int) BEGIN select pUId=utilizatorId ,pTip=tip,pEId=evenimentId from utilizator where loghin=pUser and password=pPass; END ; ");
pstmt.reset(vCon->prepareStatement("CALL fLoghin('"+vU+"','"+vP+"', @out1,@out2,@out3)"));
pstmt->execute();
pstmt.reset(vCon->prepareStatement("SELECT @out1 AS o1"));
res.reset(pstmt->executeQuery());
while (res->next()) {
cout << "\t... _answer: " << res->getInt("o1") << endl;}
pstmt.reset(vCon->prepareStatement("SELECT @out2 AS o2"));
res.reset(pstmt->executeQuery());
while (res->next()) {
cout << "\t... _answer: " << res->getInt("o2") << endl;}
pstmt.reset(vCon->prepareStatement("SELECT @out3 AS o3"));
res.reset(pstmt->executeQuery());
while (res->next()) {
cout << "\t... _answer: " << res->getInt("o3") << endl;}
vStmt->execute("DROP PROCEDURE IF EXISTS fLoghin");
and I get this error
"# ERR: Commands out of sync; you can't run this command now (MySQL error code: 2014, SQLState: HY000 )"
What i do wrong?
I have this code
string vU="demo",vP="1234";
Driver * vDriver = get_driver_instance();
auto_ptr< Connection > vCon(vDriver->connect(getHost(),getUser() , getPassword() ));
vCon->setSchema(getDB());
auto_ptr<Statement > vStmt(vCon->createStatement());
auto_ptr<PreparedStatement > pstmt;
auto_ptr<ResultSet> res;
vStmt->execute("DROP PROCEDURE IF EXISTS fLoghin");
vStmt->execute("CREATE PROCEDURE fLoghin(in pUser varchar(200),in pPass varchar(200),out pUId int,out pTip int,out pEId int) BEGIN select pUId=utilizatorId ,pTip=tip,pEId=evenimentId from utilizator where loghin=pUser and password=pPass; END ; ");
pstmt.reset(vCon->prepareStatement("CALL fLoghin('"+vU+"','"+vP+"', @out1,@out2,@out3)"));
pstmt->execute();
pstmt.reset(vCon->prepareStatement("SELECT @out1 AS o1"));
res.reset(pstmt->executeQuery());
while (res->next()) {
cout << "\t... _answer: " << res->getInt("o1") << endl;}
pstmt.reset(vCon->prepareStatement("SELECT @out2 AS o2"));
res.reset(pstmt->executeQuery());
while (res->next()) {
cout << "\t... _answer: " << res->getInt("o2") << endl;}
pstmt.reset(vCon->prepareStatement("SELECT @out3 AS o3"));
res.reset(pstmt->executeQuery());
while (res->next()) {
cout << "\t... _answer: " << res->getInt("o3") << endl;}
vStmt->execute("DROP PROCEDURE IF EXISTS fLoghin");
and I get this error
"# ERR: Commands out of sync; you can't run this command now (MySQL error code: 2014, SQLState: HY000 )"
What i do wrong?