0

我是hibernate和heroku的新手。我在 heroku 上创建了一个数据库,并尝试使用我的 eclipse 插件访问数据库 - hibernate 以生成 POJO 类。我收到类似“读取架构错误:获取数据库元数据”的错误。我检查了用户名、密码、数据库名称..一切似乎都是正确的,我无法连接 PGAdmin 工具(访问 Postgres 数据库)。

你能帮我把heroku数据库和eclipse hibernate插件连接起来吗?

    <?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">org.postgresql.Driver</property>
    <property name="hibernate.connection.password">xxxxxx</property>
    <property name="hibernate.connection.url">jdbc:postgresql://xxxxx:5432/xxxxx</property>
    <property name="hibernate.connection.username">xxxxxxx</property>
    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <property name="hibernate.default_schema">xxxxxx</property>
</session-factory>

任何帮助表示赞赏!

4

2 回答 2

1

我找到了我的问题的解决方案。我必须使用 ssl 连接,所以网址是:

<property name="hibernate.connection.url">jdbc:postgresql://xxxx-host-xxxx:5432/xxx-database-xxx?sslfactory=org.postgresql.ssl.NonValidatingFactory&amp;ssl=true</property>
于 2013-11-04T14:58:46.690 回答
0

安装 Heroku Toolbelt,然后输入heroku config. 以这种形式获取 DATABASE_URL 的每个部分:postgres://username:password@host:port/dbname

这适用于 PGAdmin,并且应该适用于任何其他 Postgres 兼容工具。请注意,Heroku 经常使用非标准端口。

于 2013-11-04T13:20:05.963 回答