8 Replies Latest reply on Nov 5, 2009 6:29 PM by phantasmo

    Seam-gen fails to connect to PostgreSQL

    phantasmo

      I am using seam-gen from Eclipse. I can't seem to reverse-engineer entities because it always says couldn't connect to the database. When I manually try to obtain the connection using


      Class.forName("org.postgresql.Driver");  
        Connection con=DriverManager.getConnection("jdbc:postgresql://localhost/test","postgres", "p");



      (same parameters), it works ok. No such problems with MySQL datasource.


      Any ideas what might be causing this?


      Thanks for the time...

        • 1. Re: Seam-gen fails to connect to PostgreSQL
          phantasmo
          Here's my hibernate-console.properties:

          #File used by hibernate tools to override <datasource> and other container specific settings in persistence.xml
          hibernate.connection.password=p
          hibernate.connection.username=postgres
          hibernate.connection.driver_class=org.postgresql.Driver
          hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
          hibernate.connection.url=jdbc\:postgresql\:test

          hibernate.connection.provider_class=org.hibernate.connection.DriverManagerConnectionProvider
          hibernate.datasource=
          hibernate.transaction.manager_lookup_class=

          Does this look right to you? At least I'd like to know if this is the only file I should look into for problems.

          Any advice is appreciated.
          • 2. Re: Seam-gen fails to connect to PostgreSQL
            tmalatinszki

            hibernate.connection.url looks a bit weird...try this:


            hibernate.connection.url=jdbc:postgresql://localhost:5432/test



            Regards,


            Tamas

            • 3. Re: Seam-gen fails to connect to PostgreSQL
              phantasmo

              Thanks, but I did try it already. The version displayed above relies on the defaults, but I tried with the proper notation (the one you mentioned), but to no avail.

              • 4. Re: Seam-gen fails to connect to PostgreSQL
                phantasmo

                So, hibernate-console.properties is the only relevant file, right?

                • 5. Re: Seam-gen fails to connect to PostgreSQL
                  tmalatinszki

                  No, this property file is required for Hibernate Console, the problem should be in Your persistence.xml or in the datasource (xxxx-ds.xml) file.
                  Could You show these files?


                  Regards,


                  Tamas

                  • 6. Re: Seam-gen fails to connect to PostgreSQL
                    phantasmo

                    Thanks for the interest in helping.


                    Here's test-ds.xml:


                    <local-tx-datasource>
                        <jndi-name>testDatasource</jndi-name>
                        <use-java-context>true</use-java-context>
                        <connection-url>jdbc:postgresql:test</connection-url>
                        <driver-class>org.postgresql.Driver</driver-class>
                        <user-name>postgres</user-name>
                        <password>p</password>
                    </local-tx-datasource>
                    



                    and here's persistence.xml:


                    <persistence-unit name="test" transaction-type="JTA">
                          <provider>org.hibernate.ejb.HibernatePersistence</provider>
                          <jta-data-source>java:/testDatasource</jta-data-source>
                          <properties>
                             <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
                             <property name="hibernate.hbm2ddl.auto" value="update"/>
                             <property name="hibernate.show_sql" value="true"/>
                             <property name="hibernate.format_sql" value="true"/>
                             <!-- Only relevant if Seam is loading the persistence unit (Java SE bootstrap) -->
                             <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
                          </properties>
                       </persistence-unit>
                    
                    



                    All URLs have been tested in both the short and long form.

                    • 7. Re: Seam-gen fails to connect to PostgreSQL
                      tmalatinszki

                      Have You tried to change connection-url in test-ds.xml like this?


                      <connection-url>jdbc:postgresql://localhost:5432/test</connection-url>



                      This is the only possibly incorrect line in Your code...


                      Regards,


                      Tamas

                      • 8. Re: Seam-gen fails to connect to PostgreSQL
                        phantasmo

                        Sadly, yes... It seems to be the case of what I call "the ghost activity". Nothing but Seam Tools has any problem connecting to the database with these settings...