20

Looking at the maven central repository the newest jdbc4 driver available for PostGresql is only the 9.1 driver

http://mvnrepository.com/artifact/postgresql/postgresql/9.1-901.jdbc4

There is a newer file called "postgresql-9.2-1002.jdbc4.jar" available on http://jdbc.postgresql.org/download.html but it has not been released to Maven central.

benstpierre
  • 32,833
  • 51
  • 177
  • 288
  • Neither are the versions 9.2-1000, 9.2-1001. See jdbc driver [changelog](http://jdbc.postgresql.org/changes.html)... – Guillaume Husta Dec 12 '12 at 21:34
  • 4
    It's a manual step, and the PgJDBC folks are all very busy doing other things. We had someone working on automating the PgJDBC releases to Central using maven-ant-tasks, but they seeem to have vanished. Everybody wants this, but it's very hard to find people willing to spend any time actually improving the JDBC driver and its release processes. Are you willing to help out? Post on the psql-jdbc mailing list if so. – Craig Ringer Dec 12 '12 at 23:56
  • @CraigRinger I can do it if I only knew how to build the JDBC3 jar. I tried setting some properties (`-Djdbc4=false and -Djdbc3=true`) but various crap broke (I assume I need an older JDK). – Adam Gent Dec 31 '12 at 22:59

5 Answers5

25

It seems like PostgreSQL has updated their groupId to org.postgresql instead of postgresql.

So now it is possible to use maven directly (mvnrepository.com):

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.2-1002-jdbc4</version>
</dependency>
maba
  • 47,113
  • 10
  • 108
  • 118
8

Following dependency description works for me:

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.2-1002-jdbc4</version>
</dependency>
user2083084
  • 81
  • 1
  • 2
6

(This answer is now outdated; the jars have been released to maven under the groupid org.postgresql. See more recent answers for details.)

You can simply install the driver to your local ~/.m2 repository. See the maven documentation and this question.

mvn install:install-file \
  -DgroupId=postgresql \
  -DartifactId=postgresql \
  -Dpackaging=jar \
  -Dversion=9.2-1002.jdbc4 \
  -Dfile=postgresql-9.2-1002.jdbc4.jar \
  -DgeneratePom=true

Alternately, if you're using Sonatype Nexus to manage repositories and caching - which I highly recommend - then you can add the jar to a locally maintained repository in your Nexus instance.

Community
  • 1
  • 1
Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
  • What if another developer needs to work on this project and doesn't have that jar installed in his local repo? That makes the build not portable. – SergeyB Oct 15 '13 at 16:02
  • @ike_love Then you'd use a shared Nexus instance among the team. The PgJDBC team really needs volunteers to help with Maven releases and some other admin work. – Craig Ringer Oct 19 '13 at 04:02
4

You may use TypeSafe repository, it contains 9.2 driver. Use:

    <repository>
      <id>typesafe</id>
      <url>http://repo.typesafe.com/typesafe/repo/</url>
    </repository>

I hope that 9.2 driver will be on central repository soon, check https://github.com/pgjdbc/pgjdbc/issues/46 for progress.

user815114
  • 118
  • 6
0

I added the 9.2-1002 driver to my own crappy Maven repository that is hosted by Google Code (github wasn't popular a long time ago when I made it).

    <repository>
        <id>mvn-adamgent</id>
        <url>http://mvn-adamgent.googlecode.com/svn/maven/release</url>
        <name>Adam Gent Maven Repository</name>
    </repository>

I tried to go and fix the postgres build to build me a JDBC3 driver but I think you have to install an older JDK to get that working so I just grabbed the jars from: http://jdbc.postgresql.org/download.html

    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.2-1002.jdbc4</version>
    </dependency>

I also included a source jar (so Maven will auto download the source for you) but I did not make Javadoc or JDBC3 jar.

If I only knew how to make the JDBC3 jar correctly I could make the changes to their build file (@Craig Ringer) on my github fork.

Adam Gent
  • 47,843
  • 23
  • 153
  • 203
  • Compile the JDBC3 driver by using JDK 1.4 or 1.5. If that isn't explained in the readme then I really need to fix it; I'll check. We don't build the JDBC3 driver with a newer JDK because Java frustratingly lacks a `-stdlib 1.4` flag or something that excludes *standard library* features. `-source 1.4 -target 1.4` is therefore insufficient to make sure the produced driver will *actually run* on older JDKs. – Craig Ringer Jan 01 '13 at 03:07
  • Ha ha it does say it in he readme :) I guess I got a little ADD and missed that. – Adam Gent Jan 01 '13 at 14:52