MySQL Forums
Forum List  »  Connector/C++

Re: C++ mySQL connection failed
Posted by: Peter Brawley
Date: August 19, 2021 03:00PM

I haven't done C++ for a while, but to me the connection code looks incomplete, I would've expected something more like ...

#include <mysql/mysql.h>

using namespace std;

int main() {
  MYSQL *conninit, *conn;
  MYSQL_RES *res_set;
  MYSQL_ROW row;
  if( !conninit=mysql_init(NULL) ) return 1;
  if( !( conn=mysql_real_connect( conninit, ... ) ) {
    fprintf( stderr, "Connection failed %s\n", mysql_error(conninit) );
    mysql_close(conn);
    return 2;
  }
  ...



Edited 1 time(s). Last edit at 08/19/2021 03:52PM by Peter Brawley.

Options: ReplyQuote


Subject
Views
Written By
Posted
2881
August 19, 2021 02:03AM
951
August 19, 2021 11:45AM
Re: C++ mySQL connection failed
970
August 19, 2021 03:00PM
1078
August 19, 2021 03:51PM
1336
August 19, 2021 05:42PM
871
August 20, 2021 08:00AM
891
August 20, 2021 10:42AM
934
August 20, 2021 11:43AM
1024
August 20, 2021 01:28PM


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.