# [FAQ] JDCB 连接 TiDB 应用报错 "Could not retrieve transation read-only status"

## Key Words

JDBC, 应用, max-active

## Description

预计创建 100 个 TiDB 连接会话，实际只生成 50 个连接会话，如何排查参数配置？

关键报错信息 “Could not retrieve transaction read-only status from server”

应用 JDCB 配置连接 TiDB 报错信息；

```text
org.springframework.dao.TransientDataAcoessResourceExoeption:
### Error querying database. Cause: java sq| SQLException: Could not retrieve transaction read-only status from server
### The error may exist in com/bocsoft/dbsp/busi/mapper/inf/DataProcessinfoMapperjava (best guess)
### The error may involve com. bocsoft.dbsp.busi.mapper.infDataProcessinfoMapper.getDataProcessinfo
## The error occurred while executing a query
### Cause: java.sqi.SQLException: Could not retrieve transaction read-only status from server
Could not retrieve transaction read-only status from server; nested exception is java.sq SQLException Could not retrieve transaction read-only status from server
at org.springframework.jdbc. support SQLStateSQLException Translator. do Translate (SQLStateSOLException Translator java:110)
at org.springframework.jdbc. support.AbstractFallbackSQL Exception Translator. translate (AbstractFallbackSQLException Translator java: 72)
at org.springframework.jdbc. support.AbstractFallbackSQ
```

## Content

基于报错 “Could not retrieve transaction read-only status from server” 的排查顺序方法：

1. Client 端采用的 mysql-connector 版本是多少？建议使用最新的版本或者 mysql 5.7/8.0 兼容版本；
2. 是否在 client 链接建立会话模式中，配置了 session 级别的 session.tx_read_only，会导致事务直接报错；
3. 确认一下 tidb 设置 wait_time 参数是否设置较短，具体值是多少？虽不会导致以上信息报错，但可能因为设置过小，导致 JDBC 建立 session 被 cancel;
4. JDBC 中配置 max-active 设置太小，最大连接数据库数量过小，设置为 0 为不设限，导致创建 TiDB 连接失败，积压请求线程在 JDBC 等待线程池；

## Affected Versions

N/A