php mysql中间件原理_数据库几个中间件的关系及大致原理 - mybatis、druid、shading-jdbc...

mysql架构示意图:

0c459117ffbb8915faa30db9cc572002.png

f593cea05bb36caa2588dd0fd4104c48.png

最原始的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向下递归调用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值