在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:CxxDBC开源软件地址:https://gitee.com/cxxjava/CxxDBC开源软件介绍:CxxDBC基于C++开发的异种数据库跨平台连接中间件.目录特点
示例
#include "Edb.hh"#include "ELog.hh"#define LOG(fmt,...) ESystem::out->println(fmt, ##__VA_ARGS__)#define HOST "127.0.0.1"#define PORT "6633"#define DATABASE "test"#define USERNAME "test"#define PASSWORD "password"static void test_db_execute() { EConnection conn; //默认使用proxy模式 conn.connect(DATABASE, HOST, atoi(PORT), USERNAME, PASSWORD); ECommonStatement stmt(&conn); EResultSet* rs; //0. try { stmt.setSql("DROP TABLE mysql000").execute(); } catch (...) { } stmt.setSql("CREATE TABLE mysql000 (" "id integer NULL," "name varchar (40) NULL ," "date date NULL" ") type=InnoDB").execute(); //1. stmt.setSql("insert into mysql000 values(?,?,?)") .bindInt(4) .bindString("1") .bindString("2017-07-08"); for (int i=0; i<100; i++) { stmt.execute(); } //2. stmt.setSql("select * from mysql000").execute(); rs = stmt.getResultSet(); EResultSetMetaData* rsm = rs->getMetaData(); LOG(rsm->toString().c_str()); while (rs->next()) { for (int i=1; i<=rs->getMetaData()->getColumnCount(); i++) { LOG("%s:%s", rs->getMetaData()->getColumnLabel(i).c_str(), rs->isNull(i) ? "is null" : rs->getString(i).c_str()); } } rs->close(); conn.close();}int main(int argc, const char **argv) { // CxxJDK init. ESystem::init(argc, argv); // CxxLog4j init. ELoggerManager::init("log4e.properties"); try { test_db_execute(); } catch (ESQLException& e) { e.printStackTrace(); } catch (...) { printf("catch all...\n"); } ESystem::exit(0); return 0;} 更多示例:esql.cppmssql.cppmysql.cpporacle.cpppostgres.cppsybase.cpp 架构
集成详见使用指南 依赖TODO
SupportEmail: [email protected] |
请发表评论