代码拉取完成,页面将自动刷新
统一接口,支持各类异种数据库的连接访问;
c++ client API参考jdbc,简洁易用;
c++ client支持数据库连接池;
c++ client支持静态链接数据库直连
、动态加载数据库直连
、dbproxy代理访问
、混合访问模式
等多种模式;
使用dbproxy代理进行数据库连接
模式时,支持黑白名单、SSL安全连接、最大连接数控制、SQL访问记录、(SQL安全审计、读写分离等高级功能持续开发中...);
client语言支持列表:
语言 | 支持情况 |
---|---|
c++ | 支持 |
其他 | TODO |
数据库支持列表:
数据库 | 读、写 | 多结果集 | 批量写 | 存储过程 | LOB读写 | 参数绑定 | 事务 | 限制 |
---|---|---|---|---|---|---|---|---|
MySQL | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 存储过程仅支持结果集返回 |
PostgreSQL | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 存储过程仅支持结果集返回 |
Oracle | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 存储过程仅支持游标返回 |
MSSQL | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 存储过程仅支持结果集返回,且不支持参数绑定模式 |
Sybase | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 存储过程仅支持结果集返回,且不支持参数绑定模式 |
其他 | TODO | TODO | TODO | TODO | TODO | TODO | TODO |
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.cpp mssql.cpp mysql.cpp oracle.cpp postgres.cpp sybase.cpp
非CxxDBC常见模式:
CxxDBC模式一:静态链接数据库直连
CxxDBC模式二:动态加载数据库直连
CxxDBC模式三:dbproxy代理访问
CxxDBC模式四:混合访问模式
集合模式二
和模式三
的混合模式,图略。
详见使用指南
Email: cxxjava@163.com
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型