標準APIを使ったサンプル
#include <stdio.h>
#include <bzs/db/protocol/tdap/client/database.h>
#include <bzs/db/protocol/tdap/client/table.h>
#include <bzs/db/protocol/tdap/client/dbDef.h>
using namespace bzs::db::protocol::tdap::client;
using namespace bzs::db::protocol::tdap;
void showError(const _TCHAR* caption, const _TCHAR* tableName, short statusCode)
{
_TCHAR tmp[1024] = { 0x00 };
_tprintf(_T("[ERROR] %s No.%ld %s\n"), caption, statusCode, tmp);
}
bool openDbExclusive(
database* db,
const _TCHAR* uri)
{
db->
open(uri, TYPE_SCHEMA_BDF, TD_OPEN_EXCLUSIVE);
{
showError(_T(
"open daatabase"), NULL, db->
stat());
return false;
}
return true;
}
#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
int result = 1;
static const _TCHAR* uri = _T("tdap://localhost/test?dbfile=test.bdf");
if (openDbExclusive(db, uri))
{
showError(_T(
"drop daatabase"), NULL, db->
stat());
if (result == 0)
_tprintf(_T("Drop daatabase success. \n"));
}
return result;
}
コンビニエンスAPIを使ったサンプル
#include <bzs/db/protocol/tdap/client/trdboostapi.h>
#include <iostream>
using namespace bzs::db::protocol::tdap::client;
using namespace bzs::db::protocol::tdap;
#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
try
{
_T("test"));
prams.setMode(TD_OPEN_EXCLUSIVE);
std::cout << "Drop databse success." << std::endl;
return 0;
}
catch (bzs::rtl::exception& e)
{
std::tcout << _T("[ERROR] ") << *bzs::rtl::getMsg(e) << std::endl;
}
return 1;
}