2 Replies Latest reply on Apr 3, 2002 4:46 PM by Tom

    Example for Jboss 3.0 + Postgres [on Linux]?

    Tom Newbie

      I've successfully deployed session beans to both JBoss 2.4 and jboss 3.0 beta, but am really struggling to tie an entity bean to my postgres database in either jboss. Can someone point me to a fairly comprehensive example of tying my postgres DB to a usable JBoss datasource? My areas of greatest confusion are how to specify my database in JBoss's config files so that I can refer to the datasource name in my deployment files.

      I don't have my code & errors available, but when I last worked on it, it looked as though it was generating the proper SQL for Postgres, but attempting to execute it through an "hsql" object, which failed. Sorry to be so vague right now, but an example I could learn from and customize would help me immensely right now.


        • 1. Re: Example for Jboss 3.0 + Postgres [on Linux]?
          Gary A. Clark Newbie

          Here is what I have done to get JBoss and PostgreSQL to work together.

          In jboss.jcml, make sure you have added the driver 'org.postgresql.Driver' to the JdbcProvider mbean and that the PostgreSQL jdbc driver is in the classpath when jboss starts.

          For the database I want to access, I cut-and-paste one of the XADataSourceLoader beans and modify:

          jdbc: postgresql://localhost:5432/jboss

          (NOTE: There is no space after jdbc: in the URL, but if I don't put one there in this forum, you will see :p instead)

          I've left out some of the attributes you will need to keep and only listed those I change. The name attribute of the mbean tag needs a new name. The pool name needs a new name. URL needs to be changed. User and password need to be set, even if you don't use passwords, it won't work if you leave this out or leave it blank (I.E. put something in there!)

          There was a change I made to the standardjaws.xml file to make boolean values work as well.


          This worked for me, but YMMV.

          • 2. Re: Example for Jboss 3.0 + Postgres [on Linux]?
            Tom Newbie

            Thanks! I got things working a few hours after posting that, but it's nice to have confirmation of what to pay attention to.

            I have a working "Person" entity bean now and am adding new finder methods and features to it to help me learn more about its use. I'll be posting the whole example with notes here soon.

            I guess I'm assuming I'm not the only one who had troubles building and understanding the supplied examples, primarily because of the undocumented difficulties with DB integration. It's the little things that trip me up, like not setting my commit options to B or C and then wondering where my data went.