Skip site navigation (1) Skip section navigation (2)

JDBC driver throws unfriendly exceptions

From: Jered Floyd <jered(at)permabit(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Cc: dev-server(at)permabit(dot)com
Subject: JDBC driver throws unfriendly exceptions
Date: 2001-02-07 08:13:49
Message-ID: (view raw or whole thread)
Lists: pgsql-bugs
                        POSTGRESQL BUG REPORT TEMPLATE

Your name		:	Jered Floyd
Your email address	:	jered(at)permabit(dot)com

System Configuration
  Architecture (example: Intel Pentium)  	: x86

  Operating System (example: Linux 2.0.26 ELF) 	: Linux 2.2.17

  PostgreSQL version (example: PostgreSQL-7.0):   PostgreSQL-7.0.3

  Compiler used (example:  gcc 2.8.0)		: gcc 2.95.2

Please enter a FULL description of your problem:

While using the JDBC driver:
Attempting to access data from a ResultSet (with getXXX(), etc.) before
calling causes a NullPointerException to be thrown at
the deference of this_row[] at

Yes, I'm a bonehead for trying to access the row data before calling
next(), but this isn't the ideal thing to have happen. The driver should
catch this case (by checking this_row[] or catching the exception) and
throw something more descriptive.

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible: 

After construcing a PreparedStatement ps:
  int i;
  ResultSet rs = ps.executeQuery();
  if (rs != null) 
    i = getInt(1);

If you know how this problem might be fixed, list the solution below:

As I mention above, the driver should catch this case and throw a more
descriptive exception. It's inappropriate and un-neighborly to go
around throwing exceptions like NullPointerException or

I think (hope) the JDBC driver is a moving target, so I'll take a look
at this issue when I move over to using 7.1beta (after I've beaten 7.0
into submission.)

pgsql-bugs by date

Next:From: Jered FloydDate: 2001-02-07 08:15:06
Subject: JDBC driver doesn't allow access to BYTEA types via get/setBytes()
Previous:From: Nat HowardDate: 2001-02-07 05:19:58
Subject: 7.1beta4 jdbc problem on freebsd 4.2 with JSDK 1.1.8.

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group