#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Cannot create PoolableConnectionFactory.Check hostname and port and postmaster


    I upgraded from postgresql 8.4 to 9.2 and hibernate complains the following
    WARN 02-26-13 07:25:51:198 PublishAcceptor.GridResourceLocation org.hibernate.cfg.SettingsFactory Could not obtain connection metadata
    org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.)
    at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceCo nnectionProvider.java:80)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)

    Following are the details
    1. Web application on Tomcat
    2. Java platform
    3. OS linux centOS
    4. Upgraded from Postgres 8.4 to 9.2
    5. Upgraded to latest JDBC 4 driver postgresql-9.2-1002.jdbc4.jar

    I used pg_upgrade for the actual upgrade.
    I have tried the following
    1. ps -aux | grep postgres lists all my postgres processes with their expected ports
    2. Telnet to localhost and port works fine
    3. Listen address in postgresql.conf file is 'localhost'
    4. Authentication method in pg_hba.conf file is 'trust'
    5. psql -U <USER> -p <PORT> -d <DB> works fine
    6. psql postgresql://<USER>@localhost:5432/<DB> works fine
    7. I have also searched a few forums but no success

    I did not change any of the previous hibernate properties which worked fine with 8.4
    From the exception it is clear that hibernate cannot get to the post master but I have no clue why.

    Please let me know what I am missing here.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,786
    Rep Power
    349
    Listen address in postgresql.conf file is 'localhost'
    That means that you can only connect from the same machine where Postgres is running. Where is your Tomcat installed?

    psql postgresql://<USER>@localhost:5432/<DB> works fine
    What do you mean with that? That's not a valid connection information for psql.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by shammat
    That means that you can only connect from the same machine where Postgres is running. Where is your Tomcat installed?

    What do you mean with that? That's not a valid connection information for psql.
    I am sorry i forgot to mention, My tomcat runs on same machine as postgres.

    As for using 'psql postgresql://<USER>@localhost:5433/<DB>'
    I got that from postgres's app-psql.html page
    Frankly I included that only to mention what works
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,786
    Rep Power
    349
    Are you sure Hibernate is using the same username?

    What is the JDBC URL you are using?
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

IMN logo majestic logo threadwatch logo seochat tools logo