1.Java代码: 1.1 entity类: User.java public class User { private int userId; private String userName; private String password; private String comment; //这里要添加 setter and getter 略 } 1.2 DAO类: UserDao.java public interface UserDao { public int insertAndGe…
1.String类型(此类型是数字格式的字符串类型)转换成Int类型 String str = "10000"; 转换成Int类型: int num = Integer.parseInt(str); 得到的结果是:int类型的10000 2.int类型转换成String类型 int n = 1000; n = n +1; String str = String.valueOf(n); // 或者另外一种转换方式: String st = n +""; 得到的结果是…
我们都知道Mybatis在插入单条数据的时候有两种方式返回自增主键: 1.对于支持生成自增主键的数据库:useGenerateKeys和keyProperty. 2.不支持生成自增主键的数据库:<selectKey>. 但是怎对批量插入数据返回自增主键的解决方式网上看到的还是比较少,至少百度的结果比较少. Mybatis官网资料提供如下: First, if your database supports auto-generated key fields (e.g. MySQL and SQL…