2013-11-04 32 views
0

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

你能帮助我连接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> 

任何帮助表示赞赏!

回答

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> 
+0

需要大约3分钟的时间才能建立连接,对此有何解决方案? –

0

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

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

+0

我试过你的建议仍然无法连接。 – dotnetrocks