有的教程mysql是8.0版本使用jar包不一样
mysql mysql-connector-java 8.0
然后我查了一下我的mysql版本是5.7版本,然后我就改成
mysql mysql-connector-java 5.7
结果还是报错。无语… 最后才想出来这里的 version是jar包的版本,不是mysql的版本。
mysql mysql-connector-java 5.1.38
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: java.sql.SQLException: Column count doesn't match value count at row 1
### The error may exist in mappers/UserMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into t_user value (null,'admin','123456',23,'123456@qq.com')
### Cause: java.sql.SQLException: Column count doesn't match value count at row 1Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
```false
一开始的mybatis-config.xml如下所示:```java
value="jdbc:mysql://localhost:3306/MyBatis"/>
修改为:
https://blog.csdn.net/m0_37987151/article/details/84316008
上午设置了mybatis-config模板。然后再创建文件名为:mybatis-config.xml后,文件图标成为了灰色
情况如下:
解决方法:
从上图的recognized file types中找和mybatis-config.xml灰色图标,然后发现:
1号箭头中也有mybatis-config.xml。这就是导致文件变灰色的原因。所以删掉2号箭头的内容即可。
maven导入依赖时,如果出现大量的红线。
则是因为没有设置好maven仓库。
测试方法的时候不知道在哪运行
解决方法:忘记加注解:@Test
没加@Test 之前:
加了@Test 之后:
有一种错误可能:
jdbc.properties文件设置jdbc.password的时候,密码为123456后面可能不小心打出了一个空格。
修改后:
#{}会自动加单引号
&{}需要手动加单引号
P35MyBatis批量删除中
删除id为1,2,3的数据。语句:
delete from t_user where id in (${ids}) // 正 确delete from t_user where id in (#{ids}) // 错 误
因为id是int类型所以不需要加引号,而#{}会自动加单引号。所以需要使用&{}
自测:删除username为admin的数据
delete from t_user where username in (#{username}) // 正确delete from t_user where username in (${username}) // 错误
因为username是String类型所以引号,而${}需要手动加单引号。所以需要使用#{}
路径在输入的时候是:com.atguigu.mybaits.mappers
文件在输入的时候是:com/atguigu/mybaits/mappers
上一篇:对CAS的理解