Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can one .war file be built with both 8.4 and 9.0 postgres (hibernate) libraries?

We've been using maven dependencies to specify the libraries so far, i.e.:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>3.6.10.Final</version>
</dependency>
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-c3p0</artifactId>
  <version>3.6.10.Final</version>
  <type>jar</type>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>8.4-702.jdbc4</version>
</dependency>

However, we are now running the exact same .war file on different machines, and would like to keep the same One-war-file-to-rule-them-all, but don't want to hit issues by using an older driver on a postgres 9.1 installation (especially when byte array encoding defaults have changed, for example). Cliff-Claven esque like information that probably won't matter but added anyway: OS for both of these installations are Mac OS X Server, the Postgres 8.4 one is running on 10.6, the 9.1 one is running on 10.7. We have no need to upgrade any data (separate instances started from scratch).

Perhaps it's more of a maven question than anything else, but I couldn't seem to see anything specific to my situation. I did find this, but it's older Hibernate 3.5 which doesn't apply anymore.

like image 467
Scott Corscadden Avatar asked Apr 17 '12 12:04

Scott Corscadden


1 Answers

For PostgreSQL, the latest version of the JDBC driver should be used regardless of the version of the server, except for truly extremely ancient versions.

http://jdbc.postgresql.org/download.html#current says:

This is the current version of the driver. Unless you have unusual requirements (running old applications or JVMs), this is the driver you should be using. It supports Postgresql 7.2 or newer and requires a 1.4 or newer JVM.

For the PostgreSQL JDBC driver, as bugs are fixed and features added they generally go only into the latest version. Newer JDBC driver versions are aware of older server versions and will behave correctly according to the server version.

Note that older JDBC drivers are not aware of newer server versions, and in fact you can cause security problems by using a JDBC driver older than the server version.

like image 101
kgrittn Avatar answered Sep 30 '22 03:09

kgrittn