1 2 Previous Next 16 Replies Latest reply on Feb 26, 2005 7:03 AM by Wael Hamama Go to original post
      • 15. Re: JBoss plus PostgreSQL
        Niko Schmuck Newbie

        I found the problem, first the property password is case-sensitive

        sa

        The content does not matter (in the case accessing it from the localhost), but it has not the be empty, take care :)

        And the next thing i got was another error message while starting up:

        [INFO,PostgresDS] Connection refused. Check that the hostname and port is correct, and that the postmaster is running with the -i flag, which enables TCP/IP networking.

        So this is pretty easy to solve, thanks to the good error message! I can only highly recommend to turn on logging:

        true

        otherwise the startup just hangs without any helpful message.

        -- Niko

        • 16. Re: JBoss plus PostgreSQL
          Wael Hamama Newbie


          if your application is web application then :-

          In web.xml add the following lines:-

          <resource-ref >
          <res-ref-name>jdbc/MyDSName</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>CONTAINER</res-auth>
          <res-sharing-scope>Shareable</res-sharing-scope>
          </resource-ref>

          In the C:\jboss-3.2.2\server\YourApp\deploy , you must create the postgres-ds.xml file :

          <?xml version="1.0" encoding="UTF-8"?>

          <!-- ===================================================================== -->
          <!-- -->
          <!-- JBoss Server Configuration -->
          <!-- -->
          <!-- ===================================================================== -->

          <!-- $Id: postgres-ds.xml,v 1.1.2.1 2003/09/05 16:38:24 patriot1burke Exp $ -->



          <local-tx-datasource>
          <jndi-name>PostgresDS</jndi-name>
          <connection-url>jdbc ostgresql://yourserver ort/appcontext</connection-url>
          <driver-class>org.postgresql.Driver</driver-class>
          <user-name>user</user-name>
          password

          <!-- sql to call when connection is created
          <new-connection-sql>some arbitrary sql</new-connection-sql>
          -->

          <!-- sql to call on an existing pooled connection when it is obtained from pool
          <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
          -->

          </local-tx-datasource>



          And finally, you have to create a jboss-web.xml in your WEB-INF app directory as follows :


          <?xml version="1.0" encoding="UTF-8"?>
          <jboss-web>
          <resource-ref>
          <res-ref-name>jdbc/MyDSName</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <jndi-name>java:/PostgresDS</jndi-name>
          </resource-ref>
          </jboss-web>

          Then , in order to get the DS object, you have this code (using JNDI) :

          ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/MyDSName");


          1 2 Previous Next