JDBC 6.5.1-2 Bug? - Mailing list pgsql-bugs

From Bill Chatfield
Subject JDBC 6.5.1-2 Bug?
Date
Msg-id 38095D90.153D9F92@netcommunity.com
Whole thread Raw
List pgsql-bugs
============================================================================

                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================



Your name  : Bill Chatfield
Your email address : bill.chatfield@netcommunity.com


System Configuration
---------------------
  Architecture (example: Intel Pentium)   : Intel Pentium

  Operating System (example: Linux 2.0.26 ELF)  : Red Hat 6.0

  PostgreSQL version (example: PostgreSQL-6.4.2)  :   PostgreSQL-6.4.2

  Compiler used (example:  gcc 2.8.0)  : Standard Red Hat PostgreSQL was
used
                        gcc version egcs-2.91.66 19990314/Linux
(egcs-1.1.2 release)


Please enter a FULL description of your problem:
------------------------------------------------

JDBC driver 6.5.1-2.rpm causes exception on connect failure:

java.lang.ArrayIndexOutOfBoundsException
 at java.text.MessageFormat.format(MessageFormat.java:238)
 at java.text.MessageFormat.format(MessageFormat.java:230)
 at postgresql.util.PSQLException.translate(PSQLException.java:83)
 at postgresql.util.PSQLException.<init>(PSQLException.java:45)
 at postgresql.Driver.connect(Driver.java:106)
 at java.sql.DriverManager.getConnection(DriverManager.java:61)

This doesn't happen with the 6.3 JDBC driver.  6.3 says:
Conect: The user property is missing. It is mandatory.

Additional question:  why is the user property mandatory if I'm
connecting
locally?  When I run psql it just uses my Linux login name.  Why can't
the jdbc do that?

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

Use Red Hat 6.0.  Install postgres-jdbc-6.5.1-2.rpm.  Use /usr/bin/java
or
/opt/jdk117_v3 (generates different error but same idea).  Use the
following code.


import java.io.*;
import java.sql.*;

class Pj

 public static void main(String argv[])
 {
  Connection db = null;

  try
  {
   Class.forName("postgresql.Driver");
   db = DriverManager.getConnection("jdbc:postgresql:dbname");
   try
   {
    Statement st = db.createStatement();
    try
    {
     ResultSet rs = st.executeQuery("select * from users");
     while (rs.next())
     {
          System.out.print("Column 1 returned ");
          System.out.println(rs.getString(1));
     }
     rs.close();
    }
    catch (SQLException e)
    {
     System.err.println("Exec: " + e.getLocalizedMessage());
    }
    st.close();
   }
   catch (SQLException e)
   {
    System.err.println("Statement: " + e.getLocalizedMessage());
   }
  }
  catch (ClassNotFoundException e)  // Class.forName error
  {
   System.err.println("No driver: " + e.getLocalizedMessage());
  }
  catch (SQLException e)  // getConnection error
  {
  }

  try
  {
   if (db != null)
    db.close();
  }
  catch (SQLException e)
  {
   System.err.println("Close: " + e.getLocalizedMessage());
  }

 }



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

No clue.

pgsql-bugs by date:

Previous
From: Peter Schaefer
Date:
Subject: default operator (int8le?)
Next
From: "Damien Silveira"
Date:
Subject: postgresbug.txt