使用druid连接池,配置sql防火墙发现的sql注入问题

最近在使用druid连接池,同时也配置了web和spring的关联监控,检测到select * from tables param like #{param1} “%”的语句被拦截了。做个笔记。

解决方法有两种:

一、 select * from tables param like concat(${param1},”%”)。

二、传入 参数的时候动态拼接 param1=param1+”%”;

select * from tables param like #{param1}。

Mybatis3 防止SQL注入

{xxx},使用的是PreparedStatement,会有类型转换,所以比较安全;

${xxx},使用字符串拼接,可以SQL注入;

like查询不小心会有漏动,正确写法如下:

Mysql: select * from tables where param like concat(‘%’, #{param1}, ‘%’)

Oracle: select * from t_user where param like ‘%’ || #{param1} || ‘%’

SQLServer: select * from t_user where param like ‘%’ + #{param1} + ‘%’

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-07-29 08:18:08

使用druid连接池,配置sql防火墙发现的sql注入问题的相关文章

Spring Boot2.x 的Druid连接池配置[附带监控]

父依赖[Spring Boot 2.1.x版本] <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.1.RELEASE</version> </parent> 主要依赖[3个] <!--Druid 连接池与Spring B

druid连接池配置

阿里巴巴推出的国产数据库连接池,据网上测试对比,比目前的DBCP或C3P0数据库连接池性能更好,Druid与其他数据库连接池使用方法基本一样(与DBCP非常相似),将数据库的连接信息全部配置给DataSource对象. 基于纯Java代码使用: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 package demo.test; import java.io.I

阿里巴巴Druid连接池配置

Druid 是阿里巴巴的开源数据库连接池技术,相比dbcp.c3p0更优秀,具有密码加密.sql连接监控功能,无论在性能还是稳定性上表现都十分出色. spring.xml <context:property-placeholder location="classpath:jdbc.properties"/> <bean id="druidDataSource" class="com.alibaba.druid.pool.DruidData

SpringBoot2.0 基础案例(07):集成Druid连接池,配置监控界面

一.Druid连接池 1.druid简介 Druid连接池是阿里巴巴开源的数据库连接池项目.Druid连接池为监控而生,内置强大的监控功能,监控特性不影响性能.功能强大,能防SQL注入,内置Loging能诊断Hack应用行为.Druid连接池是阿里巴巴内部唯一使用的连接池,在内部数据库相关中间件TDDL/DRDS 都内置使用强依赖了Druid连接池,经过阿里内部数千上万的系统大规模验证,经过历年双十一超大规模并发验证. 2.druid特点 1)稳定性特性,阿里巴巴的业务验证 2)完备的监控信息,

SpringMVC+Spring+Mybatis整合,使用druid连接池,声明式事务,maven配置

一直对springmvc和mybatis挺怀念的,最近想自己再搭建下框架,然后写点什么. 暂时没有整合缓存,druid也没有做ip地址的过滤.Spring的AOP简单配置了下,也还没具体弄,不知道能不能用,log也不知道能不能用,`(*∩_∩*)′哈哈,有点不负责任...... 直接上代码: 使用的eclipse和eclipse自带的maven,参考了网上的资料,有些代码是拷贝的,不过都自己测试过了.嗯,可以跑起来... 先上项目结构: 新建maven项目,选择web,然后配置pom: <pro

【Mysql】SpringBoot阿里Druid数据源连接池配置

一.pom.xml添加 <!-- 配置数据库连接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.0</version> </dependency> 二.application.properties 添加 # 连接池配置spring.datasource.type

spring 4 + jpa(hibernate 3/4) + spring mvc 多数据源配置(二)+Druid连接池

接上一个博文(http://www.loveweir.com/html/18.html),没有数据库连接池,纯粹用jpa的官方链接. 所以这次要加上连接池本文用Druid连接池来实现多数据源的配置. persistence.xml 这个文件可以省略了,全部配置在applicationContext.xml 里面: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www

Druid连接池及监控在spring中的配置

Druid连接池及监控在Spring配置如下: [html] view plaincopy <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <!-- 基本属性 url.user.password --> <property 

SpringBoot配置MySql数据库和Druid连接池

1.pom文件增加相关依赖,我这里因为上面引入了父pom,所以不需要在当前pom文件下加版本 <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifact