MySQL Forums
Forum List  »  Connector/C++

Get Error but query works
Posted by: Thorsten Petersen
Date: October 06, 2009 06:58AM

I wrote a program which is reading all the time data from a table in a loop

	try{
  sql::Driver *driver;
  sql::Connection *con;
  sql::Statement *stmt;
  sql::ResultSet *res;

 driver = get_driver_instance();
  con = driver->connect("localhost:3306", "root", "");

 con->setSchema("bgame");
	
  stmt = con->createStatement();
  
 while(1){
  

	
  stmt = con->createStatement();

  sprintf(sql_query, "SELECT * FROM buildquery WHERE zeit<=%d Order by zeit DESC",time(NULL));
	res = stmt->executeQuery(sql_query);

while (res->next()) {


// ...  edit some results -> get sz,sz2,sz3,sz4 (they are correct) ...

sprintf(sql_up_query, "Update villages Set %s=%s+1 Where vid='%s'  ",sz2,sz2,sz);
	stmt->executeQuery(sql_up_query);

	

	sprintf(sql_del_query, "Delete from buildquery Where id=%s  ",sz4);
	stmt->executeQuery(sql_del_query);

  }

 }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;
}
-------

The querys work and the first updates the table
but after that I get an error :

#ERR: SQLException in .\buildquery.cpp(main) on line 164
#ERR: (MySQL error code: 0, SQLState: 00000

and the program stop reading and editing the table

How can I do it right?

Sorry for my bad english - I´m german ;)

Options: ReplyQuote


Subject
Views
Written By
Posted
Get Error but query works
3238
October 06, 2009 06:58AM


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.