【问题标题】:accessing heroku database with hibernate eclipse plugin使用 hibernate eclipse 插件访问 heroku 数据库
【发布时间】:2013-11-04 13:03:05
【问题描述】:

我是 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>

感谢任何帮助!

【问题讨论】:

    标签: eclipse hibernate postgresql heroku


    【解决方案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>
    

    【讨论】:

    • 建立连接大约需要 3 分钟,有什么解决方案吗?
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2019-11-21
      • 1970-01-01
      • 2021-05-19
      • 1970-01-01
      • 1970-01-01
      • 2011-03-16
      • 1970-01-01
      • 2012-11-02
      • 1970-01-01
      相关资源
      最近更新 更多