testdb.cpp
来自「天之炼狱1服务器端源文件游戏服务端不完整」· C++ 代码 · 共 53 行
CPP
53 行
#include <iostream>#include "Types.h"#include "Exception.h"#include "Connection.h"#include "Statement.h"#include "Result.h"#include "LogManager.h"#include "Properties.h"int main(){ try { g_pConfig = new Properties(); g_pConfig->load("/home/crazydog/Works/VampireSlayers/conf/gameserver.conf"); g_pLogManager = new LogManager(); g_pLogManager->start(); Connection * pConn = new Connection( "localhost" , "PLAYER", "choon", "choon" , 7777 ); Statement * pStmt = pConn->createStatement(); Result * pResult = pStmt->executeQuery("SELECT PID, ID, Name, Passwd FROM Player"); cout << "SELECT PID, ID, Name, Passwd FROM Player" << endl; while( pResult->next() ) { cout << "Player(PID:" << pResult->getInt(1) << " ID:" << pResult->getString(2) << ",Name:" << pResult->getString(3) << ",Password:" << pResult->getString(4) << ")" << endl; } // Statement 俊辑 捞傈 Result 绰 磊悼栏肺 昏力茄促. // 宝洒 寇何俊辑 瘤快霸 登搁 榜摹酒橇促. - -; pResult = pStmt->executeQuery("SELECT ID, Name, Passwd FROM Player WHERE id = 11"); cout << "SELECT ID, Name, Passwd FROM Player WHERE id = 11" << endl; // SELECT 搬苞 炼扒阑 父练窍绰 巴捞 酒公巴档 绝促搁, RowCount 啊 0 捞促. cout << "#Rows : " << pResult->getRowCount() << endl; cout << "#Cols : " << pResult->getFieldCount() << endl; while( pResult->next() ) { cout << "Player(PID:" << pResult->getInt(1) << " ID:" << pResult->getString(2) << ",Name:" << pResult->getString(3) << ",Password:" << pResult->getString(4) << ")" << endl; } delete pStmt; delete pConn; } catch ( Throwable & t ) { cout << t.toString() << endl; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?