网站首页 > 数据库 / 正文
环境:springboot2.2.11 + shardingsphere4.0.1 + mybatis + oracle做分表操作。
shardingsphere4.0.1不支持oracle中的nvarchar数据类型,源码如下:
源码:
AbstractUnsupportedOperationResultSet.java
...
@Override
public final String getNString(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getNString");
}
@Override
publicfinal String getNString(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getNString");
}
....
这两个方法是final修饰的,所以要先重写AbstractUnsupportedOperationResultSet这个类将final去掉:
修改如下,去掉final修饰符。
@Override
public String getNString(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getNString");
}
@Override
public String getNString(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getNString");
}
重写ShardingResultSet.java
添加getNString两个方法
public String getNString(final int columnIndex) throws SQLException {
return (String) ResultSetUtil.convertValue(mergeResultSet.getValue(columnIndex, String.class), String.class);
}
public String getNString(final String columnLabel) throws SQLException {
int columnIndex = columnLabelAndIndexMap.get(getActualColumnLabel(columnLabel));
return (String) ResultSetUtil.convertValue(mergeResultSet.getValue(columnIndex, String.class), String.class);
}
shardingsphere坑比较多,与数据库驱动版本,mybatis的分页插件的版本都有一定的关系。
在我的项目中一开始用的分页插件版本是4.x版本结果遇到分页就报错,升级5.x版本后好了,好了!!!
关注,转发,谢谢!!!!
SpringBoot 分库分表sharding-sphere
SpringBoot分库分表sharding-sphere2
SpringBoot分库分表sharding-sphere3
SpringBoot2 整合 OAuth2 资源认证(保护)
Tags:jdbc for oracle
猜你喜欢
- 2024-11-26 Spring boot管理系统,架构简单易懂,二次开发便捷
- 2024-11-26 Spring-Spring整合MyBatis详解
- 2024-11-26 如何使用JDBC操作数据库?一文带你吃透JDBC规范
- 2024-11-26 葵花宝典之数据库类面试真题10道(二)
- 2024-11-26 Mybatis的两个全局配置
- 2024-11-26 ShardingSphere-JDBC的功能
- 2024-11-26 解析-我们来看看Java应用中如何去使用Proxool
- 2024-11-26 开发应用程序:React、GraphQL、Spring Data JPA、UCP,Oracle
- 2024-11-26 Spring系列面试题
- 2024-11-26 「软帝学院」28道java基础面试题-下