// max_allowed_packet.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include using namespace std; class MySql { public: MySql() { mysql = mysql_init(NULL); } ~MySql() { if(mysql) { mysql_close(mysql); } } int Connect(const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag) { MYSQL *tmp = NULL; tmp = mysql; tmp = mysql_real_connect(tmp, host,user, passwd, db, port, unix_socket, clientflag); if(!tmp) { return 1; } if(mysql !=tmp) mysql_close(mysql); mysql = tmp; return 0; } int Execute(const char *query) { int status = mysql_real_query(mysql, query,strlen(query)); cout<<"Error:"<net.last_error; return mysql->net.last_errno; } private: MYSQL * mysql; }; void syncmysqldbs(); void insertfunc(); int main(int argc, _TCHAR* argv[]) { int i = mysql_library_init(0, NULL, NULL); insertfunc(); return 0; } void insertfunc() { MySql mysqlsrc; char *query; FILE *file; file = fopen("D:\\blob6.sql", "r"); long lSize; char * buffer; size_t result; if (file==NULL) {fputs ("File error",stderr);} // obtain file size: fseek (file , 0 , SEEK_END); lSize = ftell (file); rewind (file); // allocate memory to contain the whole file: buffer = (char*) malloc (sizeof(char)*lSize); if (buffer == NULL) {fputs ("Memory error",stderr); } // copy the file into the buffer: result = fread (buffer,1,lSize,file); if (result != lSize) {fputs ("Reading error",stderr); } if(mysqlsrc.Connect("localhost","root", "root", NULL, 3306, NULL, CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS)) { cout<<"Connection Failed"; return; } int error = 0; while (error != 1153) { error = mysqlsrc.Execute(buffer); cout<