Difference: PostgresqlAndJ2ee (2 vs. 3)

Revision 303 Apr 2001 - TobyCabot

Line: 1 to 1
Changed:
<
<
Sun's reference j2ee server (j2sdk1.2.1) will work with Postgresql, although it's not a supported configuration and therefore probably not a great idea for production systems. I like the combination, though, since my machines are resource constrained and I'm usually running Postgresql anyway - I'd rather not have another JVM running to handle database queries.
>
>
Sun's reference j2ee server (j2sdk1.2.1 and j2sdk1.3) will work with Postgresql, although it's not a supported configuration and therefore probably not a great idea for production systems. I like the combination, though, since my machines are resource constrained and I'm usually running Postgresql anyway - I'd rather not have another JVM running to handle database queries.
  The steps to follow are:
  • install the software, and get everything working with Cloudscape. This may seem like a waste of time but it's not - it establishes a baseline.
Line: 23 to 23
  First find the postgresql.jar file (it's in /usr/share/java on my Debian box) and copy it to $J2EE_HOME/lib/system (according to the j2ee docs it needs to be there for security reasons). Then edit $J2EE_HOME/bin/userconfig.sh so that =$J2EE_CLASSPATH includes postgresql.jar.
Added:
>
>
1.2.1:
 Edit $J2EE_HOME/config/default.properties. First look for the line that looks like:

jdbc.drivers=COM.cloudscape.core.RmiJdbcDriver

Line: 37 to 39
  I suppose this is somewhat misleading but it requires the fewest changes from the Cloudscape configuration.
Added:
>
>
1.3:

Edit $J2EE_HOME/config/resource.properties. Add a line:

jdbcDriver.1.name=org.postgresql.Driver

and then change

jdbcDataSource.0.url=jdbc:cloudscape:rmi:CloudscapeDB;create=true

to

jdbcDataSource.0.url=jdbc:postgresql:account

 Change the user ID in the beans
Deleted:
<
<
l
 The Cloudscape server doesn't seem to use the jdbc user/password that postgresql does so you'll need to add it to your beans. In the deploytool you choose the bean (say "AccountBean") in the left pane then choose the "Resource Ref's" tab at the top of the right pane. Select the resource factory whose name is "jdbc/AccountDB" and you'll see that the "Deployment Settings" box at the bottom will now allow you to enter a JNDI name (which has to match the one in the jdbc.datasources, e.g. jdbc/Cloudscape, and a username and password. You can now save and deploy the application. (As an aside: if you're building the .ear by hand you'll need to put these values in the META-INF/sun-j2ee-ri.xml file).

Go for it!

Line: 46 to 62
 Run the AccountClient client and bask in the glory that is postgresql and java. A few troubleshooting notes:

  • You don't really get much feedback from the console that you run the client from. Take a look at $J2EE_HOME/logs/{hostname}/ejb/j2ee/error.log , there's probably a stack trace there that will help.
Changed:
<
<
  • You need to clean the account table out after every run or else you'll get a PK violation. delete from account;
>
>
  • You need to clean the account table out after every run or else you'll get a PK violation. In 1.2.1 delete from account; or in 1.3 delete from myaccount;.
 
  • Cloudscape seems to be more forgiving in terms of casting rules than postgresql so you'll probably get an exception about needing to use an explicit cast. This patch to AccountEJB.java should work:


View topic | History: r3 < r2 < r1 | More topic actions...
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback