{"id":13635469,"url":"https://github.com/houbb/jdbc-pool","last_synced_at":"2025-04-10T18:31:26.786Z","repository":{"id":57720086,"uuid":"280387768","full_name":"houbb/jdbc-pool","owner":"houbb","description":"The jdbc pool for java.(java 手写 jdbc 数据库连接池实现)","archived":false,"fork":false,"pushed_at":"2024-03-20T02:44:16.000Z","size":102,"stargazers_count":19,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T02:51:25.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/houbb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-17T09:48:02.000Z","updated_at":"2025-02-23T16:10:57.000Z","dependencies_parsed_at":"2023-01-22T06:45:48.047Z","dependency_job_id":"52f80989-03cf-4b89-865f-eb0a9b927cca","html_url":"https://github.com/houbb/jdbc-pool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fjdbc-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fjdbc-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fjdbc-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fjdbc-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/houbb","download_url":"https://codeload.github.com/houbb/jdbc-pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248271696,"owners_count":21075800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T00:00:45.976Z","updated_at":"2025-04-10T18:31:26.166Z","avatar_url":"https://github.com/houbb.png","language":"Java","funding_links":[],"categories":["测试"],"sub_categories":["客户端"],"readme":"# 项目简介\n\n[jdbc-pool](https://github.com/houbb/jdbc-pool) 是一款简化版的 jdbc-pool 实现。\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.houbb/jdbc-pool/badge.svg)](http://mvnrepository.com/artifact/com.github.houbb/jdbc-pool)\n[![Build Status](https://www.travis-ci.org/houbb/jdbc-pool.svg?branch=master)](https://www.travis-ci.org/houbb/jdbc-pool?branch=master)\n[![](https://img.shields.io/badge/license-Apache2-FF0080.svg)](https://github.com/houbb/jdbc-pool/blob/master/LICENSE.txt)\n[![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/houbb/jdbc-pool)\n\n## 拓展阅读\n\n第一节 [从零开始手写 mybatis（一）MVP 版本](https://mp.weixin.qq.com/s/8eF7oFxgLsilqLYGOVtkGg)。\n\n第二节 [从零开始手写 mybatis（二）mybatis interceptor 插件机制详解](https://mp.weixin.qq.com/s/83GzYTQCrWiEowN0gjll0Q)\n\n第三节 [从零开始手写 mybatis（三）jdbc pool 从零实现数据库连接池](https://mp.weixin.qq.com/s/pO1XU_PD2pHyq-bBWMAP2w)\n\n第四节 [从零开始手写 mybatis（四）- mybatis 事务管理机制详解](https://mp.weixin.qq.com/s/6Wa5AbOrg4MhRbZL674t8Q)\n\n## 创作目的\n\n- 学习 jdbc-pool 的原理\n\n- 便于拓展自己的数据库工具\n\n## 特性\n\n- 基本的数据库连接池实现\n\n- 自动适配 jdbc 驱动类\n\n- 支持各种场景对于连接的校验\n\n# 快速开始\n\n## 需要\n\n- jdk 1.7+\n\n- maven 3.x+\n\n## maven 引入\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.houbb\u003c/groupId\u003e\n    \u003cartifactId\u003ejdbc-pool\u003c/artifactId\u003e\n    \u003cversion\u003e1.7.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## 引导类\n\n```java\nJdbcPoolBs jdbcPoolBs = JdbcPoolBs.newInstance()\n                .username(\"root\")\n                .password(\"123456\")\n                .url(\"jdbc:mysql://127.0.0.1:3306/test?useUnicode=true\u0026characterEncoding=utf-8\");\n\nDataSource pooled = jdbcPoolBs.pooled();\nDataSource unPooled = jdbcPoolBs.unPooled();\n```\n\n## 测试代码\n\n```java\nUnPooledDataSource source = new UnPooledDataSource();\nsource.setDriverClass(\"com.mysql.jdbc.Driver\");\nsource.setJdbcUrl(\"jdbc:mysql://127.0.0.1:3306/test?useUnicode=true\u0026characterEncoding=utf-8\");\nsource.setUser(\"root\");\nsource.setPassword(\"123456\");\n\nConnection connection = source.getConnection();\n```\n\n## 池化的实现\n\n```java\nPooledDataSource source = new PooledDataSource();\nsource.setDriverClass(\"com.mysql.jdbc.Driver\");\nsource.setJdbcUrl(\"jdbc:mysql://127.0.0.1:3306/test?useUnicode=true\u0026characterEncoding=utf-8\");\nsource.setUser(\"root\");\nsource.setPassword(\"123456\");\nsource.setMinSize(1);\n\n// 初始化\nsource.init();\n\nConnection connection = source.getConnection();\nSystem.out.println(connection.getCatalog());\n\nConnection connection2 = source.getConnection();\nSystem.out.println(connection2.getCatalog());\n```\n\n### 输出日志\n\n```\n[DEBUG] [2020-07-18 10:50:54.536] [main] [c.g.h.t.p.d.PooledDataSource.getFreeConnection] - 从连接池中获取连接\ntest\n[DEBUG] [2020-07-18 10:50:54.537] [main] [c.g.h.t.p.d.PooledDataSource.getConnection] - 开始扩容连接池大小，step: 1\n[DEBUG] [2020-07-18 10:50:54.548] [main] [c.g.h.t.p.d.PooledDataSource.getConnection] - 从扩容后的连接池中获取连接\ntest\n```\n\n第一次默认直接从线程池中获取，第二次为重新创建的信息。\n\n# 后期 road-map\n\n- [x] 根据 url 自动识别 driverClass\n\n- [x] 添加获取的等待\n\n- [x] 添加设置为繁忙的状态 check\n\n- [x] 添加日志替代 sout\n\n- [x] 添加 validQuery, testOnBorrow, testOnReturn, testWhileIdle\n\n- [ ] 添加 filter-chain\n\n- [ ] JMX 添加各种监听的属性\n\n- [ ] 添加监控页面实现\n\n- [ ] 添加 druid/mybatis??/commons-pool 等常见的数据源\n\n# 中间件等工具开源矩阵\n\n[heaven: 收集开发中常用的工具类](https://github.com/houbb/heaven)\n\n[rpc: 基于 netty4 实现的远程调用工具](https://github.com/houbb/rpc)\n\n[mq: 简易版 mq 实现](https://github.com/houbb/mq)\n\n[ioc: 模拟简易版 spring ioc](https://github.com/houbb/ioc)\n\n[mybatis: 简易版 mybatis](https://github.com/houbb/mybatis)\n\n[cache: 渐进式 redis 缓存](https://github.com/houbb/cache)\n\n[jdbc-pool: 数据库连接池实现](https://github.com/houbb/jdbc-pool)\n\n[sandglass: 任务调度时间工具框架](https://github.com/houbb/sandglass)\n\n[sisyphus: 支持注解的重试框架](https://github.com/houbb/sisyphus)\n\n[resubmit: 防止重复提交框架，支持注解](https://github.com/houbb/resubmit)\n\n[auto-log: 日志自动输出](https://github.com/houbb/auto-log)\n\n[async: 多线程异步并行框架](https://github.com/houbb/async)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoubb%2Fjdbc-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoubb%2Fjdbc-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoubb%2Fjdbc-pool/lists"}