Re: Problem with connecting to postgres using jdbc7.0-1.2.jar - Mailing list pgsql-jdbc

From K. Ari Krupnikov
Subject Re: Problem with connecting to postgres using jdbc7.0-1.2.jar
Date
Msg-id 3C2A06DD.181F8A0D@cogsci.ed.ac.uk
Whole thread Raw
In response to Problem with connecting to postgres using jdbc7.0-1.2.jar  (Peter Adamek <peter.adamek@utoronto.ca>)
List pgsql-jdbc
Jens Carlberg wrote:
>
> > Does anyone have any suggestions?  It seems strage to me that if I
> > change the driver name that reads
> > Class.forName("org.postgresql.Driver"), I get no errors when I compile.

[...]

> If you wan't to handle it at compile time, look up the method
> DriverManager.registerDriver(Driver driver). The driver calls this
> itself when it is loaded, so it would be extra work without any good
> effects besides that you no longer need to catch CLasNotFound but a
> SQLException. :-)

You can simply say

new org.postgresql.Driver ();

The constructor (actually the static initialization) will call
registerDriver() for you.

Ari.

pgsql-jdbc by date:

Previous
From: Jens Carlberg
Date:
Subject: Re: Problem with connecting to postgres using jdbc7.0-1.2.jar
Next
From: "K. Ari Krupnikov"
Date:
Subject: org.postgresql.Connection#EscapeSQL and {d