Wiki source code of PostgresqlPlugin Framework
Version 36.1 by Pascal Robert on 2012/07/19 21:10
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | To use PostgreSQL as the persistence layer with WebObjects, you need the PostgreSQL JDBC driver and the PostgresqlPlugIn framework from Project Wonder. | ||
2 | |||
3 | = JDBC Driver = | ||
4 | |||
5 | A JDBC driver is required for WebObjects, just like for any Java application that talks to a database. You should download the driver that matches the version of PostgreSQL that you have installed from PostgreSQL's [[JDBC driver download page>>url:http://jdbc.postgresql.org/download.html||shape="rect"]]. | ||
6 | |||
7 | There are several ways to install the driver: | ||
8 | |||
9 | 1. Put the JAR in the JRE's extensions directory: {{code language="none"}}/Library/Java/Extensions{{/code}} on Mac OS X, or {{code language="none"}}$JAVA_HOME/lib/ext{{/code}} on Unix. (Be aware that putting JARs in the extensions directory carries caveats with respect to classpath references and versioning. It is loaded by the system classloader and is a global version for all of your Java applications.) | ||
10 | 1. Put the JAR in the {{code language="none"}}Libraries{{/code}} directory of a specific application. | ||
11 | 1. Create a framework containing the JAR in {{code language="none"}}Libraries{{/code}}, and then reference that framework from your applications. | ||
12 | |||
13 | {{note title="JDBC driver adjusts timestamps"}} | ||
14 | Note that the PostgreSQL JDBC driver will adjust timestamps handed to it by WebObjects into the local timezone of the machine running the JDBC driver. This will occur regardless of whether the database server was started up in UTC (by supplying {{code language="none"}}timezone=UTC{{/code}} in {{code language="none"}}postgresql.conf{{/code}}, or as a command line option). This also appears to occur regardless of whether the column type in use is {{code language="none"}}TIMESTAMP WITHOUT TIME ZONE{{/code}} (which is the type used by the {{code language="none"}}ERPrototypes.framework{{/code}} {{code language="none"}}dateTime{{/code}} prototype), or {{code language="none"}}TIMESTAMP WITH TIME ZONE{{/code}}. There are several workarounds: | ||
15 | |||
16 | 1. Obviously if machine-local time is UTC, the problem is non-existent. | ||
17 | 1. Pass the option {{code language="none"}}-Duser.timezone=UTC{{/code}} to the JVM at application launch. | ||
18 | 1. Have a static block in the application's {{code language="none"}}Application{{/code}} class (or some superclass) that sets the Java default timezone: | ||
19 | |||
20 | {{code}} | ||
21 | |||
22 | static { | ||
23 | TimeZone.setDefault(TimeZone.getTimeZone("UTC")); | ||
24 | } | ||
25 | |||
26 | {{/code}} | ||
27 | {{/note}} | ||
28 | |||
29 | {{note title="Postgresql 9.0+ and bytea columns"}} | ||
30 | In Postgresql 9.0, the default value for bytea_output changed from 'escape' to 'hex'. I've had an issue where the value written in to the db was read out incorrectly due to this. To fix the problem in PGAdmin3, right click on your database, and select the 'Properties' context menu option. In the properties window that pops up, select the 'Variables' tab, and set the value appropriately.[[image:attach:Screen shot 2011-03-01 at 9.33.42 PM.png]] | ||
31 | {{/note}} | ||
32 | |||
33 | = PostgresqlPlugin Framework = | ||
34 | |||
35 | This framework is a plugin for the WebObjects {{code language="none"}}JDBCAdaptor{{/code}} so that it is able to communicate with a PostgreSQL database server. The easiest way to get the {{code language="none"}}PostgresPlugin.framework{{/code}} is to [[install Project Wonder>>url:http://wiki.objectstyle.org/confluence/display/WO/Project+WONDER-Quickstart||shape="rect"]]. Otherwise, you can download the built frameworks from the [[WOCommunity Jenkins server>>url:http://jenkins.wocommunity.org||shape="rect"]] (either [[Wonder for WebObjects 5.3>>url:http://wocommunity.org/wonder/legacy/||shape="rect"]] or [[Wonder of WebObjects 5.4>>url:http://wocommunity.org/wonder/latest/||shape="rect"]]), extract the {{code language="none"}}PostgresqlPlugIn.framework{{/code}}, and place it in {{code language="none"}}~/Library/Frameworks{{/code}}. You must add the {{code language="none"}}PostgresPlugin.framework{{/code}} to your application's build path so that it is able to find the plugin. | ||
36 | |||
37 | = Using PostgreSQL in Entity Modeler (WOLips) = | ||
38 | |||
39 | [[image:attach:PostgresSQL-EM.png]] | ||
40 |