Thread

  1. JDBC driver throws unfriendly exceptions

    Jered Floyd <jered@permabit.com> — 2001-02-07T08:13:49Z

    ============================================================================
                            POSTGRESQL BUG REPORT TEMPLATE
    ============================================================================
    
    
    Your name		:	Jered Floyd
    Your email address	:	jered@permabit.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 ResultSet.next() causes a NullPointerException to be thrown at
    the deference of this_row[] at ResultSet.java:164.
    
    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
    ArrayIndexOutOfBoundsException.
    
    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.)