$ show alibaba/druid
Alibaba Druid is a production-grade Java library providing a high-performance JDBC connection pool, a multi-dialect SQL parser, an SQL injection firewall, and built-in monitoring/statistics. In production, it replaces or augments standard connection pools (HikariCP, DBCP) with advanced features like connection leak detection, PSCache, and web console monitoring. The SQL parser supports 30+ dialects (MySQL, PostgreSQL, Oracle, Hive, ClickHouse, etc.) and is used for SQL formatting, parameterization, and analysis. The WallFilter provides configurable security rules to block SQL injection and dangerous operations. The library integrates deeply with Spring Boot via dedicated starters for Boot 2/3/4, and exposes metrics through JMX. Architecture is organized around a filter chain pattern for intercepting JDBC calls, a visitor pattern for AST manipulation, and an SPI-based provider system for firewall rules.
The LLM identified 3 files worth highlighting for reuse:
Provides symmetric encryption and decryption for database passwords (e.g., publicKey / privateKey pair). Completely self-contained utility that can be extracted to add password encryption support to any Java project. Demonstrates careful key generation, padding, and Base64 encoding without external dependencies.
A fully functional mock JDBC driver that creates in-memory connections, statements, and result sets without a real database. Isolated and reusable for unit testing data access code. Implements Driver, Connection, Statement, PreparedStatement, ResultSet with configurable behavior via MockExecuteHandler.
Normalizes SQL statements by replacing literal values with parameters and removing comments, producing a parameterized signature. Standalone utility built on the AST visitor pattern, reusable for SQL aggregation, caching, and firewall analysis. Demonstrates careful handling of dialect-specific syntax and visitor feature flags.