Giter VIP home page Giter VIP logo

cxxdbc's Introduction

CxxDBC

基于C++开发的异种数据库跨平台连接中间件.

目录

特点

  • 统一接口,支持各类异种数据库的连接访问;

  • 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常见模式:

    arch0

  • CxxDBC模式一:静态链接数据库直连

    arch1

  • CxxDBC模式二:动态加载数据库直连

    arch2

  • CxxDBC模式三:dbproxy代理访问

    arch3

  • CxxDBC模式四:混合访问模式 集合模式二模式三的混合模式,图略。 ​

集成

详见使用指南

依赖

  1. CxxJDK
  2. CxxLog4j
  3. CxxConet

TODO

  1. SQL安全审计;
  2. ...

Support

Email: [email protected]

cxxdbc's People

Contributors

cxxjava avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.