1在数据库连接的URL后面追加allowMultiQueries=true
jdbc:mysql://localhost:3306/db0?characterEncoding=utf-8&allowMultiQueries=true
如果使用的阿里的Druid的数据库连接池,需要修改连接配置
@Bean(name = "wallFilter")
@DependsOn("wallConfig")
public WallFilter wallFilter(WallConfig wallConfig){
WallFilter wallFilter = new WallFilter();
wallFilter.setConfig(wallConfig);
return wallFilter;
}
@Bean(name = "wallConfig")
public WallConfig wallConfig(){
WallConfig wallConfig = new WallConfig();
wallConfig.setMultiStatementAllow(true);//允许一次执行多条语句
wallConfig.setNoneBaseStatementAllow(true);//允许一次执行多条语句
return wallConfig;
}
在datasource初始化的设置
List<Filter> filters = new ArrayList<>();
filters.add(wallFilter(wallConfig()));
druidDataSource.setProxyFilters(filters);