feat: fix sr hint issues (#6632) feat: fix sr hint issues fix: restore full maven test stability Keep ODPS boolean formatting from dropping precedence, clear datasource stat state between tests, and move starter module descriptors to moditect packaging so reactor builds compile cleanly.
feat: fix sr hint issues (#6632)
feat: fix sr hint issues
fix: restore full maven test stability
Keep ODPS boolean formatting from dropping precedence, clear datasource stat state between tests, and move starter module descriptors to moditect packaging so reactor builds compile cleanly.
English | 中文
Druid 是阿里巴巴开源的高性能数据库连接池和 SQL 解析器。它将 JDBC 连接池、SQL 解析分析、安全防护和监控统计深度整合为一体,是 Java 生态中功能最全面的数据库中间件之一。
DruidDataSource
WallFilter
StatFilter
HighAvailableDataSource
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.2.24</version> </dependency>
根据 Spring Boot 版本选择对应 Starter:
druid-spring-boot-starter
druid-spring-boot-3-starter
druid-spring-boot-4-starter
<!-- Spring Boot 3.x 示例 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-3-starter</artifactId> <version>1.2.24</version> </dependency>
# application.yml spring: datasource: url: jdbc:mysql://localhost:3306/mydb username: root password: password druid: initial-size: 5 max-active: 20 min-idle: 5 max-wait: 60000 # 启用 Filter filter: stat: enabled: true log-slow-sql: true slow-sql-millis: 2000 wall: enabled: true
DruidDataSource dataSource = new DruidDataSource(); dataSource.setUrl("jdbc:mysql://localhost:3306/mydb"); dataSource.setUsername("root"); dataSource.setPassword("password"); dataSource.setInitialSize(5); dataSource.setMaxActive(20); dataSource.setMinIdle(5); dataSource.init(); // 使用连接 try (Connection conn = dataSource.getConnection()) { // 执行 SQL }
// 解析 SQL String sql = "SELECT id, name FROM users WHERE age > 18 ORDER BY name"; List<SQLStatement> stmts = SQLUtils.parseStatements(sql, DbType.mysql); // 格式化 SQL String formatted = SQLUtils.format(sql, DbType.mysql); // 获取表信息 SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(DbType.mysql); stmts.get(0).accept(visitor); System.out.println("Tables: " + visitor.getTables()); System.out.println("Columns: " + visitor.getColumns());
druid/ ├── core/ # 核心库(连接池、SQL 解析、安全、监控) ├── druid-spring-boot-starter/ # Spring Boot 2.x 自动配置 ├── druid-spring-boot-3-starter/ # Spring Boot 3.x 自动配置 ├── druid-spring-boot-4-starter/ # Spring Boot 4.x 自动配置 ├── druid-wrapper/ # 包装工具 ├── druid-admin/ # 集群监控管理端 └── doc/ # 文档
Druid SQL 解析器支持 30 种数据库方言,每种方言都提供完整的 Lexer、Parser、AST 和 Visitor 实现:
git clone https://github.com/alibaba/druid.git cd druid mvn clean install
要求: Java 8+ JDK,Apache Maven 3.6+
欢迎参与 Druid 项目!请阅读 贡献指南 了解如何参与开发。
请勿通过公开 Issue 报告安全漏洞。详见 安全策略。
Druid 基于 Apache License 2.0 开源。
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
Alibaba Druid
English | 中文
Druid 是阿里巴巴开源的高性能数据库连接池和 SQL 解析器。它将 JDBC 连接池、SQL 解析分析、安全防护和监控统计深度整合为一体,是 Java 生态中功能最全面的数据库中间件之一。
核心特性
DruidDataSource,支持物理连接预热、PSCache、KeepAlive 等高级特性WallFilterSQL 安全防护,可拦截 SQL 注入、危险操作等StatFilter实时采集 SQL 执行统计、连接池状态,提供 Web 监控页面HighAvailableDataSource支持多数据源负载均衡、健康检查和故障切换快速开始
Maven 依赖
Spring Boot 项目(推荐)
根据 Spring Boot 版本选择对应 Starter:
druid-spring-boot-starterdruid-spring-boot-3-starterdruid-spring-boot-4-starter直接使用 DruidDataSource
SQL 解析器
项目模块
SQL 方言支持
Druid SQL 解析器支持 30 种数据库方言,每种方言都提供完整的 Lexer、Parser、AST 和 Visitor 实现:
文档
从源码构建
要求: Java 8+ JDK,Apache Maven 3.6+
贡献
欢迎参与 Druid 项目!请阅读 贡献指南 了解如何参与开发。
安全漏洞
请勿通过公开 Issue 报告安全漏洞。详见 安全策略。
相关阿里云产品
License
Druid 基于 Apache License 2.0 开源。