fnwind commented on issue #32946:
URL:
https://github.com/apache/shardingsphere/issues/32946#issuecomment-3342361850
Although this issue has already been closed, I’d like to leave my solution
here for reference in case someone else encounters the same problem.
I am using `sharding-jdbc-spring-boot-starter:4.1.1`,
`mybatis-plus-boot-starter:3.5.3`, and `DmJdbcDriver18:8.1.2.192`。
```xml
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>com.dameng</groupId>
<artifactId>DmJdbcDriver18</artifactId>
<version>8.1.2.192</version>
</dependency>
```
After reviewing other issues and the official extension implementations
under
[jdbc-dialect](https://github.com/apache/shardingsphere/tree/master/jdbc-dialect)
, I am **convinced that DM8 is not supported**.
In my experiments, I found that when `jdbc:dm://` cannot be matched,
ShardingSphere falls back to parsing with the MySQL dialect. MySQL obviously
cannot parse DM8’s pagination syntax, **but DM8 actually works fine with
MySQL-style pagination syntax**.
So I added a custom configuration property
`xxx.mybatis.page-interceptor-db-type=mysql` to force MyBatis-Plus’s
`PageInterceptor` to generate pagination SQL using the MySQL dialect:
```java
@Data
@ConfigurationProperties(prefix = "xxx.mybatis")
public class MybatisProperties {
private DbType pageInterceptorDbType;
}
```
```java
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(MybatisProperties
mybatisProperties) {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// ...
DbType customDbType = mybatisProperties.getPageInterceptorDbType();
if (null != customDbType) {
interceptor.addInnerInterceptor(new
PaginationInnerInterceptor(customDbType));
} else {
interceptor.addInnerInterceptor(new
PaginationInnerInterceptor());
}
return interceptor;
}
```
```yaml
spring:
shardingsphere:
datasource:
names: dm8
dm8:
type: com.alibaba.druid.pool.DruidDataSource
username: MY_APP
password: PASSWORD
driverClassName: dm.jdbc.driver.DmDriver
url: jdbc:dm://localhost:5236
xxx:
mybatis:
page-interceptor-db-type: mysql
```
At least in my project, this setup works.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]