Thread: bug - connection problem with jdk 1.7 ?

bug - connection problem with jdk 1.7 ?

From
tim.lambrechts@laposte.net
Date:
(I send this e-mail again, because I hadn't subscribed me to the mailing list)

Hello,

 I already presented on the devshed forum a connection problem to postgresql with the jdbc jar file postgresql-9.3-1100.jdbc41.jar. Nobody answered me.

Until recently I thought that the origin of the problem was maybe Eclipse, but now I have tested the same code with a recent version of another development tool, Intellij IDEA, and the problem is still the same.

That’s why I begin to think that the postgresql-9.3-1100.jdbc41.jar file doesn’t function correctly with the jdk 1.7 (version 51.0), moreover because the same code worked very well with jdk 1.6, postgresql 9.0 and postgresql-9.0-801.jdbc4.jar.

So, now I repeat the explanation of the jdbc connection problem that I gave on the devshed forum:

Recently I bought a new computer and installed a running project with upgraded versions of windows (windows 7, 64 bit), eclipse (4.3.1), java (jdk 1.7 : 51.0), postgresql (9.3) and jdbc (postgresql-9.3-1100.jdbc41.jar).

On the older versions the programs ran without any problem, but now there is an exception in the following code:

public static final String DBURL = "jdbc:postgresql:MR";
public static final String DBUSER = "postgres";

. . .

public static Connection createConnection () throws SQLException {
Properties props = new Properties();
props.setProperty("user",DBUSER);
return DriverManager.getConnection(DBURL, props);
}

. . .


A NullPointerException occurs on the line of the return, while DriverManager.getConnection(String, Properties) normally throws an SQLException.

In debugging mode the stackTrace of Throwable e says: “org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.”

The jar file is included in the build path of eclipse and the .classpath file is the same as before. It also contains the node . The Eclipse build works well and all the class files of the jar file can be opened and read.

The API documentation for the DriverManager class says: “JDBC 4.0 Drivers must include the file META-INF/services/java.sql.Driver. This file contains the name of the JDBC drivers implementation of java.sql.Driver.”
When looking in the postgresql-9.3-1100.jdbc41.jar file in Eclipse the META-INF/services/java.sql.Driver file shows one line: org.postgresql.Driver. The package org.postgresql contains the Driver.class file.

In the same way, in the Intellij development tool everything seems to be ok, until a NullPointerException is thrown on the same line:
return DriverManager.getConnection(DBURL, props);

Sorry, if this is not a bug, but until now I have had no help from postrgresql community and I'm quite stuck with this problem.

Cheers.

Tim

 

Re: bug - connection problem with jdk 1.7 ?

From
Dave Cramer
Date:
Tim,

Since this is the first time hearing about this; I'm not sure where else you went in the postgresql community.

Yes, the jar does contain the name of the driver. When you say you have a problem what does this mean. I have no problem loading the driver from code written in either eclipse or Intellij

I would need more information in order to be able to replicate this problem on my machine.

Is it possible you have another postgresql jar loading first somehow that does not have the meta data in the jar ?

Dave Cramer


On Thu, Mar 27, 2014 at 10:36 AM, <tim.lambrechts@laposte.net> wrote:
(I send this e-mail again, because I hadn't subscribed me to the mailing list)

Hello,

 I already presented on the devshed forum a connection problem to postgresql with the jdbc jar file postgresql-9.3-1100.jdbc41.jar. Nobody answered me.

Until recently I thought that the origin of the problem was maybe Eclipse, but now I have tested the same code with a recent version of another development tool, Intellij IDEA, and the problem is still the same.

That’s why I begin to think that the postgresql-9.3-1100.jdbc41.jar file doesn’t function correctly with the jdk 1.7 (version 51.0), moreover because the same code worked very well with jdk 1.6, postgresql 9.0 and postgresql-9.0-801.jdbc4.jar.

So, now I repeat the explanation of the jdbc connection problem that I gave on the devshed forum:

Recently I bought a new computer and installed a running project with upgraded versions of windows (windows 7, 64 bit), eclipse (4.3.1), java (jdk 1.7 : 51.0), postgresql (9.3) and jdbc (postgresql-9.3-1100.jdbc41.jar).

On the older versions the programs ran without any problem, but now there is an exception in the following code:

public static final String DBURL = "jdbc:postgresql:MR";
public static final String DBUSER = "postgres";

. . .

public static Connection createConnection () throws SQLException {
Properties props = new Properties();
props.setProperty("user",DBUSER);
return DriverManager.getConnection(DBURL, props);
}

. . .


A NullPointerException occurs on the line of the return, while DriverManager.getConnection(String, Properties) normally throws an SQLException.

In debugging mode the stackTrace of Throwable e says: “org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.”

The jar file is included in the build path of eclipse and the .classpath file is the same as before. It also contains the node . The Eclipse build works well and all the class files of the jar file can be opened and read.

The API documentation for the DriverManager class says: “JDBC 4.0 Drivers must include the file META-INF/services/java.sql.Driver. This file contains the name of the JDBC drivers implementation of java.sql.Driver.”
When looking in the postgresql-9.3-1100.jdbc41.jar file in Eclipse the META-INF/services/java.sql.Driver file shows one line: org.postgresql.Driver. The package org.postgresql contains the Driver.class file.

In the same way, in the Intellij development tool everything seems to be ok, until a NullPointerException is thrown on the same line:
return DriverManager.getConnection(DBURL, props);

Sorry, if this is not a bug, but until now I have had no help from postrgresql community and I'm quite stuck with this problem.

Cheers.

Tim

 


Re: bug - connection problem with jdk 1.7 ?

From
dmp
Date:
> (I send this e-mail again, because I hadn't subscribed me to the mailing list)
>
> Hello,
>
>  I already presented on the devshed forum a connection problem to postgresql with the jdbc jar file
postgresql-9.3-1100.jdbc41.jar.Nobody answered me. 
>
> Until recently I thought that the origin of the problem was maybe Eclipse, but now I have tested the same code with a
recentversion of another development tool, Intellij IDEA, and the problem is still the same. 
>
> That’s why I begin to think that the postgresql-9.3-1100.jdbc41.jar file doesn’t function correctly with the jdk 1.7
(version51.0), moreover because the same code worked very well with jdk 1.6, postgresql 9.0 and
postgresql-9.0-801.jdbc4.jar.
>
> So, now I repeat the explanation of the jdbc connection problem that I gave on the devshed forum:
>
> Recently I bought a new computer and installed a running project with upgraded versions of windows (windows 7, 64
bit),eclipse (4.3.1), java (jdk 1.7 : 51.0), postgresql (9.3) and jdbc (postgresql-9.3-1100.jdbc41.jar). 
>
> On the older versions the programs ran without any problem, but now there is an exception in the following code:
>
> public static final String DBURL = "jdbc:postgresql:MR";
> public static final String DBUSER = "postgres";
>
> . . .
>
> public static Connection createConnection () throws SQLException {
> Properties props = new Properties();
> props.setProperty("user",DBUSER);
> return DriverManager.getConnection(DBURL, props);
> }

dbConnection = DriverManager.getConnection(connectionURLString, connectProperties);

Connection URL: jdbc:postgresql://127.0.0.1:5432/key_tables

What is "jdbc:postgresql:MR"? Is this a valid URL string?

Above works fine with eclipse, jdk 1.7_45, 9.3-1101.jdbc41.jar


Test of your URL:

Connection Parameters: jdbc:postgresql:key_tables?user=danap&password=&loglevel=0
ClassNotFoundExceptionjava.lang.ClassNotFoundException: org.postgresql.Driver
SQLExeceptionjava.sql.SQLException: No suitable driver found for
jdbc:postgresql:key_tables?user=danap&password=&loglevel=0

Which would result in NULL being returned as you have indicated.

danap.

>
> . . .
>
> ~
> ~
> ~
>
> Tim