[Druid] Druid添加防火墙后执行mysql 命令:load data报错

MySQL中批量插入数据时,执行load data 的方式可以大大提高效率,语法如下:

LOAD DATA
[LOCAL]
INFILE 'file_name' INTO TABLE tbl_name
[CHARACTER SET charset_name]
[{FIELDS | COLUMNS}
[TERMINATED BY 'string']
[[OPTIONALLY] ENCLOSED BY 'char']
[ESCAPED BY 'char'] ]
[LINES [STARTING BY 'string']
[TERMINATED BY 'string'] ]

但在与Druid连接池整合时,如果添加wallFilter,会导致load 命令报错,解决方案如下:

/**
	 * 设置防火墙拦截规则
	 * @return
	 */
	private WallConfig wallConfig(){
		WallConfig config = new WallConfig();
		// 运行一次执行多条SQL
		config.setMultiStatementAllow(true);
		// 防火墙拦截loadfile SQL:https://www.jianshu.com/p/fa6e8a4210cb
		config.setDir("META-INF/druid/wall/mysql");
		//允许非基本语句的其他语句
		config.setNoneBaseStatementAllow(true);
		return config;
	}

原因请参考:https://www.jianshu.com/p/fa6e8a4210cb
另外:还有可能是MySQL数据库本身的现在,请参考:
https://github.com/actiontech/dble-docs-cn/blob/develop/3.SQL_Syntax/3.2_DML/3.2.09_LOAD_DATA.md

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页