# error: sql: driver: bad connection

- **ID:** `go/sql-driver-bad-connection`
- **Domain:** go
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

数据库连接在空闲时被服务器关闭，或网络中断，导致连接池中的连接失效。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   设置 db.SetConnMaxLifetime(时间) 定期回收旧连接
   ```
2. **** (85% success)
   ```
   实现连接池重试逻辑，捕获错误后重新获取连接
   ```

## Dead Ends

- **** — 连接已损坏，重试无意义 (95% fail)
- **** — 问题根源是连接老化，而非池大小 (60% fail)
