东西很简单,就直接展示Demo了
动态表名传参方式
java层采用@Param注解
void createMonthData(@Param("tableName") String tableName);
xml层使用${}而非#{}
CREATE TABLE ${tableName} ()
表存在性校验
<select id="isTableExist" parameterType="string" resultType="int">
select count(*) from information_schema.TABLES where table_name = #{tableName}
</select>
存在即返回1
动态表名与SQL注入防范

本文介绍了一种在Java中使用MyBatis框架动态创建表的方法,通过@Param注解传递表名参数,并在XML配置文件中使用${}
3515

被折叠的 条评论
为什么被折叠?



