You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "wtjperi2003 (via GitHub)" <gi...@apache.org> on 2026/02/10 02:24:41 UTC
[I] [Bug] mysql-connector-j驱动新版不兼容 [doris]
wtjperi2003 opened a new issue, #60634:
URL: https://github.com/apache/doris/issues/60634
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.
### Version
doris version doris-4.0.2-rc02-30d2df0459
### What's Wrong?
经过测试,发现mysql-connector-j从9.5.0版本包括9.5.0开始,查询会返回空数据,实际表里是有数据的。低于9.5.0是正常的
### What You Expected?
正常返回数据
### How to Reproduce?
java项目里,引用:
```xml
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.5.0</version>
<scope>runtime</scope>
</dependency>
```
### Anything Else?
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [I] [Bug] mysql-connector-j驱动新版不兼容 [doris]
Posted by "Ruffianjiang (via GitHub)" <gi...@apache.org>.
Ruffianjiang commented on issue #60634:
URL: https://github.com/apache/doris/issues/60634#issuecomment-3989504759
以下是复现的主要代码 @morningman
1. mybatis-plus 3.5.9
2. spring-boot 3.5.11
3. mysql-connector-j 9.6.0
4. doris doris-3.1.4-rc02-7f5ba43de6
表现结果:
1. 第一、二个url查询正常,**第三个查不到数据**
2. Group Commit的性能是一二三,越来越强
3. 第一个是mysql的默认参数,第三个是doris的默认参数**useServerPrepStmts=true**,第二个把doris默认参数改为**useServerPrepStmts=false&cacheResultSetMetadata=true**
建表
```sql
CREATE TABLE IF NOT EXISTS `t_user` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`username` VARCHAR(64) NOT NULL COMMENT '用户名',
`password` VARCHAR(128) NOT NULL COMMENT '密码',
`email` VARCHAR(128) COMMENT '邮箱',
`phone` VARCHAR(20) COMMENT '手机号',
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
) ENGINE=OLAP
UNIQUE KEY(`id`)
DISTRIBUTED BY HASH(`id`) BUCKETS 3
PROPERTIES (
"replication_num" = "3"
);
```
初始化sql
```sql
INSERT INTO `t_user` (`username`, `password`, `email`, `phone`, `create_time`, `update_time`) VALUES
('zhangsan', 'e10adc3949ba59abbe56e057f20f883e', 'zhangsan@example.com', '13800138001', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
('lisi', 'e10adc3949ba59abbe56e057f20f883e', 'lisi@example.com', '13800138002', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
('wangwu', 'e10adc3949ba59abbe56e057f20f883e', 'wangwu@example.com', '13800138003', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
('zhaoliu', 'e10adc3949ba59abbe56e057f20f883e', 'zhaoliu@example.com', '13800138004', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
('sunqi', 'e10adc3949ba59abbe56e057f20f883e', 'sunqi@example.com', '13800138005', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
('zhouba', 'e10adc3949ba59abbe56e057f20f883e', 'zhouba@example.com', '13800138006', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
('wujiu', 'e10adc3949ba59abbe56e057f20f883e', 'wujiu@example.com', '13800138007', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
('zhengshi', 'e10adc3949ba59abbe56e057f20f883e', 'zhengshi@example.com', '13800138008', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
('admin', 'e10adc3949ba59abbe56e057f20f883e', 'admin@example.com', '13800138009', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
('test', 'e10adc3949ba59abbe56e057f20f883e', 'test@example.com', '13800138010', '2026-03-03 10:00:00', '2026-03-03 10:00:00');
```
pom.xml
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.11</version>
<relativePath/>
</parent>
<groupId>com.xxx</groupId>
<artifactId>doris-jdbc</artifactId>
<version>1.0.0</version>
<name>doris-jdbc</name>
<description>doris-jdbc</description>
<properties>
<java.version>21</java.version>
<mybatis-plus.version>3.5.9</mybatis-plus.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
```
application.yml
```yaml
spring:
application:
name: doris-jdbc
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://xxx:9030/demo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&sessionVariables=group_commit=async_mode
# url: jdbc:mysql://xxx:9030/demo?useServerPrepStmts=false&cacheResultSetMetadata=true&useLocalSessionState=true&rewriteBatchedStatements=true&cachePrepStmts=true&prepStmtCacheSqlLimit=99999&prepStmtCacheSize=50&sessionVariables=group_commit=async_mode
url: jdbc:mysql://xxx:9030/demo?useServerPrepStmts=true&useLocalSessionState=true&rewriteBatchedStatements=true&cachePrepStmts=true&prepStmtCacheSqlLimit=99999&prepStmtCacheSize=50&sessionVariables=group_commit=async_mode
username: root
password: xxx
server:
port: 8080
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: deleted
logic-delete-value: 1
logic-not-delete-value: 0
mapper-locations: classpath:mapper/*.xml
```
User
```java
@Data
@TableName("t_user")
public class User {
/**
* 主键ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 邮箱
*/
private String email;
/**
* 手机号
*/
private String phone;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
}
```
UserMapper
```java
@Mapper
public interface UserMapper extends BaseMapper<User> {}
```
UserService
```java
public interface UserService extends IService<User> {}
```
UserServiceImpl
```java
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {}
```
UseServiceQueryTest
```java
@SpringBootTest
@Slf4j
class UseServiceQueryTest {
@Autowired
private UserService userService;
@Test
@DisplayName("测试查询用户")
void testGetUserById() {
User foundUser = userService.getById(1L);
assertNotNull(foundUser, "查询到的用户不应该为空");
log.info("foundUser username: {}", foundUser.getUsername());
List<User> users = userService.list(new Page<>(1, 10));
log.info("users size: {}", users.size());
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [I] [Bug] mysql-connector-j驱动新版不兼容 [doris]
Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman closed issue #60634: [Bug] mysql-connector-j驱动新版不兼容
URL: https://github.com/apache/doris/issues/60634
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [I] [Bug] mysql-connector-j驱动新版不兼容 [doris]
Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman commented on issue #60634:
URL: https://github.com/apache/doris/issues/60634#issuecomment-4000560939
Thank you for providing the detailed reproduction steps.
We have successfully reproduced this issue on our end. We are currently working on a fix and will update this thread once it is resolved.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [I] [Bug] mysql-connector-j驱动新版不兼容 [doris]
Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman commented on issue #60634:
URL: https://github.com/apache/doris/issues/60634#issuecomment-3988698617
Thank you for reporting this issue. Special thanks to @Ruffianjiang for the valuable clue regarding `useServerPrepStmts=true`.
It appears there is a compatibility issue between Doris and newer versions of `mysql-connector-j` (9.5.0+) when server-side prepared statements are enabled.
To help us diagnose the root cause more efficiently, could you please provide **complete reproduction steps**?
The dependency information you provided is helpful, but a minimal, reproducible Java code snippet would be highly appreciated. Please include:
1. The complete JDBC connection URL (including any parameters).
2. The table creation statement.
3. The Java code used to insert test data and execute the query that returns empty results.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org