📄 数据库一些说明.cpp
字号:
H:\网页\MySQL Lists mysql Re undefined reference to 'mysql_init'.htmHi Ali> Hi,> I am begeener to MySQL. I have installed Suse10 and MySQL and mysql++ > in my> pc.>> i want to connect to MySQL through C. When I am compiling the program,> I am getting the following error.> ***********************************************************************compile your app with the command bellow gcc -o test -L/usr/lib/mysql -lmysqlclient test.cRegardsLuiz查一下路径 which mysql//#include <stdio.h>#include "db_operator.h"#include "policy.h"#include"define.h"#include"log.h"#define BACK_SUCCEEDED 0int main( void ){ /** 日志初始化 **/ CLog Log; char BackFile[] = BAK_LOG_PATH; char LogFile[] = LOG_FILE; char Logpath[] = LOG_PATH; /** 数据库初始化 **/ CDB_Operator* db = new CDB_Operator; if( db == NULL ) { printf( "Alloc memory error\n" ); return 1; } char szDBIP[16] = "192.168.1.58"; unsigned short uPort = 1433; char szUserName[16] = "root"; char szPasswd[16] = "123456"; char szDBName[16] = "mysql"; /** 时间过滤filter the time of net-user **/ CStyTime tTimeSeg; /** URL过滤 **/ vector<CkeyWord> tUrlVec; /** IP过滤 **/ vector<CkeyWord> tIPvec; /** 端口过滤 **/ vector<CkeyWord> tPortVec; /** 地址过滤 **/ vector<CkeyWord> tAddrVec; //用于存储查询出来的关键字; /** 初使化日志 **/ Log.InitLogFile(LogFile,LOG_NORMAL,BackFile,PROTOCOL_NUM); /** 初使化数据库 **/ if( !db->init(szDBIP, uPort, szUserName, szPasswd,szDBName) ) { printf( "Init db error!"); return 1; } //登录 if (db->connectDB()) //BOOL TYPE { printf("connectDB OK"); } else { //等待登陆成功 while (!db->re_connectDB())//BOOL TYPE { printf("Connect Has been waiting"); } } vector<CkeyWord> keyword; //用于存储查询出来的关键字; KeyWordType keyType; //初始化keyType; keyType = SUBJECT; PluginType ePlugin; //初始化ePlugin; ePlugin = HTTP; FuncType eFucType; //初始化eFuncType; eFucType = PUB; //关键字过滤 keyword是根据keyType, ePlugin, eFucType的值作为参数在数据库db中查询出来的结果。 if ( fltKeyWord(db, keyword/*IN*/, keyType/*OUT*/, ePlugin/*IN*/, eFucType/*IN*/) != BACK_SUCCEEDED) { Log.write_log(LOG_NORMAL,LogFile,1,Logpath); } /*********************************************************************** ************************************************************************ ************************************************************************ else if (fltTime(db ,tTimeSeg,ePlugin,eFucType)!= BACK_SUCCEEDED ) { //int fltTime(CDB_Operator* dbop ,CStyTime& tTimeSeg, PluginType ePlugin,FuncType eFuncType) Log.write_log(LOG_NORMAL,LogFile,1,&tTimeSeg); } else if (fltUrl(db,tUrlVec,ePlugin,eFuncType)!= BACK_SUCCEEDED) { //int fltUrl(CDB_Operator* dbop ,vector<CkeyWord>& tUrlVec,PluginType ePlugin , FuncType eFuncType) Log.write_log(LOG_NORMAL,LogFile,1,&tTimeSeg); } else if (fltIP(db,tIPvec,ePlugin,eFuncType)!= BACK_SUCCEEDED) { //int fltIP(CDB_Operator* dbop ,vector<CkeyWord> &tIPvec,PluginType ePlugin,FuncType eFuncType) Log.write_log(LOG_NORMAL,LogFile,1,&tIPvec); } else if (fltPort(db,tPortVec,ePlugin,eFuncType)!= BACK_SUCCEEDED) { //int fltIP(CDB_Operator* dbop ,vector<CkeyWord> &tIPvec,PluginType ePlugin,FuncType eFuncType) Log.write_log(LOG_NORMAL,LogFile,1,&tIPvec); } else if(fltAddress(db,tAddrVec,eEmlAddrType,ePlugin,eFuncType)!= BACK_SUCCEEDED) { Log.write_log(LOG_NORMAL,LogFile,1,&tAddrVec); } ************************************************************************ ************************************************************************ ************************************************************************ */ Log.CloseLogFile (); //关闭日志 //if( !db->closeDB() ) //{ //printf( "Close data base error" ); //} //回收内存空间 delete db; return 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -