在jdbc的连接属性url中加上&allowMultiQueries=true
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ai_hotel?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
jdbc.username=root
jdbc.password=1234
mybatis中就可以使用多条sql语句了,使用;隔开
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xjj.dao.InitDao">
<update id="initTable">
<!--新建admin表-->
create table if not exists admin(
admin_id int primary key auto_increment comment '员工号',
admin_phone varchar(11) unique comment '手机号',
);
<!--新建客户表-->
create table if not exists user(
user_id int primary key auto_increment comment '用户id',
user_name varchar(50) not null comment '用户姓名',
);
</update>
</mapper>