方便更快捷的说明问题,可以按需填写(可删除)
使用环境:
<spring-boot.version>3.0.2</spring-boot.version>
org.apache.shardingsphere
shardingsphere-jdbc
5.5.0
org.apache.shardingsphere
shardingsphere-test-util
场景、问题:
public static List<String> getAllTableNameBySchema() {
List<String> res = new ArrayList<>();
try {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
URL resource = classLoader.getResource("sharding.yaml");
DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(new File(resource.getPath()));
log.info("dataSource:{}", dataSource.hashCode());
Connection connection = null;
Statement st = null;
try {
connection = dataSource.getConnection();
st = connection.createStatement();
try (ResultSet rs = st.executeQuery("show tables like 'saas_file_%'")) {
while (rs.next()) {
String tableName = rs.getString(1);
log.error("tableName==>{}", tableName);
res.add(tableName);
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}finally {
if(connection!=null){
st.close();
connection.close();
}
}
log.info("获取数据库中所有文件存储表名:{}", res);
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
关于:ResultSet rs = st.executeQuery(“show tables like ‘saas_file_%’”)
获得的表:
实际的表:
已进行操作:
现状:
第一个表被截取掉了,这是啥原因啊?