javaEEday09-Mybatis-基础操作-删除(预编译SQL)
This commit is contained in:
@@ -6,7 +6,8 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface EmpMapper {
|
||||
//定义方法
|
||||
@Delete("delete from emp where id = #{id};")
|
||||
@Delete("delete from emp where id = #{id};")//#{}预编译的方式
|
||||
// @Delete("delete from emp where id = ${id};")//${}拼接的方式,有sql注入问题
|
||||
int delete(Integer id);//想返回删除数据的个数
|
||||
// void delete(Integer id);//不想获得删除数据的个数
|
||||
}
|
||||
|
||||
@@ -4,3 +4,5 @@ spring.datasource.url= jdbc:mysql://localhost:3306/mybatis
|
||||
spring.datasource.username= root
|
||||
spring.datasource.password= 1234
|
||||
spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driver
|
||||
|
||||
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
Reference in New Issue
Block a user