<property name="connection.url">
<![CDATA[
jdbc:mysql://172.16.109.48:3306/db_hibernate?useUnicode=true&characterEncoding=utf-8
]]>
</property>
1.在main方法中连接数据库则出现:
java.sql.SQLException: null, message from server: "Host 'macrotea' is not allowed to connect to this MySQL server"
然而这种配置,以web的方式,连接数据库,则不出错
改成如下:
jdbc:mysql://localhost:3306/db_hibernate?useUnicode=true&characterEncoding=utf-8
因此在main中测试,不报错,可以连接数据库
即使修改了hosts
127.0.0.1 172.16.109.48
尚未有效果,估计要进行mysql的设置
本文记录了一个关于使用不同方式连接MySQL数据库遇到的问题。在main方法中尝试连接时出现主机不允许连接的错误,但在web环境中正常。通过更改连接URL为localhost解决了问题。
1655

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



