java.sql.SQLException: null, message from server: "Host 'macrotea' is not allow

<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的设置

你可能感兴趣的:(java,sql,Hibernate,mysql,SQL Server)