我很难让我的程序通过Hibernate连接到MySQL数据库。
我只是想连接它,所以我可以使用Hibernate工具对数据库中的几个表进行反向工程。 当我使用MySQL Workbench从同一台机器连接到数据库时,它可以工作。
这是我的hibernate.cfg.xml
文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://www.soosthebasement.nl:3306/soos_thebasement</property>
<property name="hibernate.connection.username">removed</property>
<property name="hibernate.connection.password">removed</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>
密码包含一些奇怪的字符,例如&gt;,在创建cfg文件时,它被解析为>
。这可能与它有关吗?
答案 0 :(得分:1)
原来我使用了错误的网址。 即使问题中列出的URL指向正确的网站,它实际上并不指向数据库主机。