mybatis数据库连接一直报错不知道是什么原因,查了很久,求大佬帮帮
本帖最后由 白砂糖 于 2022-5-20 00:09 编辑项目连接如下,我用的mysql8
链接:https://pan.baidu.com/s/11zZGx4PCLxGeP_Y4CflBUg
提取码:2022
还未学到 mybatis,查到一些看看对你有没有帮助:
MySQL 8.0 以上,将配置文件中的:
<property name="url" value="jdbc:mysql://localhost:3306/onlinedb"/>
改成:
<property name="url" value="jdbc:mysql://localhost:3306/onlinedb?useUnicode=true&characterEncoding=utf8"/>
其他方法参考看看这篇文章:https://blog.csdn.net/qq_45829231/article/details/115470643 <configuration>
<settings>
<setting name="cacheEnabled" value="false"></setting>
<setting name="useGeneratedKeys" value="true"></setting>
<setting name="defaultExecutorType" value="REUSE"></setting>
</settings>
<typeAliases>
<typeAlias alias="Student" type="db.mybatis.vo.Student" />
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="jdbc" />
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jc.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3308/mytest8" />
<property name="username" value="root" />
<property name="password" value="root" />
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="mapper.ClassMapper" />
</mappers>
</configuration> 改了很多遍还是不行
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);提示我这句话有问题
页:
[1]