zoukankan      html  css  js  c++  java
  • 数据库几个中间件的关系及大致原理

    mysql架构示意图:

    最原始的JDBC实现(mysql-connctor-java): 加载JDBC驱动程序 → 建立数据库连接Connection → 创建执行SQL的语句Statement(preparedStatement) → 处理执行结果ResultSet → 释放资源

     

    DataSource->Connection->Statement

     

    DataSource的核心方法:

    public interface DataSource extends CommonDataSource,Wrapper {

      Connection getConnection() throws SQLException;

      Connection getConnection(String username, String password)
      throws SQLException;
    }

    Connection核心api:

    public interface Connection extends Wrapper, AutoCloseable {

      Statement createStatement() throws SQLException;

      PreparedStatement prepareStatement(String sql) throws SQLException;

      CallableStatement prepareCall(String sql) throws SQLException;

      void setAutoCommit(boolean autoCommit) throws SQLException;

      boolean getAutoCommit() throws SQLException;

      void commit() throws SQLException;

      void rollback() throws SQLException;

      void close() throws SQLException;

      boolean isClosed() throws SQLException;
    }

    Statement核心API定义,执行静态的sql:

    public interface Statement extends Wrapper, AutoCloseable {

      ResultSet executeQuery(String sql) throws SQLException;

      int executeUpdate(String sql) throws SQLException;

      void close() throws SQLException;

      boolean execute(String sql, String columnNames[]) throws SQLException;

      boolean isClosed() throws SQLException;

      public boolean isCloseOnCompletion() throws SQLException;

    }


    ibatis的核心应该是重写statement

    sharding-jdbc核心应该也是对statement

    druid核心应该是Connection

    各个中间件通过Statement的execute向下递归调用

     

  • 相关阅读:
    元旦晚会
    CF906D Power Tower
    基于51单片机的多功能秒表(校赛作品)
    集训队第二次排位赛
    《史记》——五帝本纪第一,黄帝部分
    原创,让你的 "Ajax"请求华丽转身,给 "body" 或是 "Div" 加上Loading遮罩!
    Excel导出通用操作方式
    图片(img标签)的onerror事件,你有用过嘛?
    @Url.ActionLink 和 @Url.Action
    原创,自己做的一个简单实用的提示小插件,兼容性很好,基本上都兼容!
  • 原文地址:https://www.cnblogs.com/yipihema/p/10190616.html
Copyright © 2011-2022 走看看