Thread: Connection problems

Connection problems

From
PaulU71555@aol.com
Date:
Hi.  I've been here before, with a similar problem...

My setup:

I'm using Red Hat 7.2...
Postmaster started by user Postgres with -i option (in /etc/rc.d/rc.local: su -c 'nohup /usr/bin/postmaster -i -D /usr/local/pgsql/data >/var/log/postmaster 2>&1 &" postgres)...
I've tried with pgjdbc1.jar in CLASSPATH and with pgjdbc2.jar in CLASSPATH...
I compile with javac -target 1.1...
I'm using j2sdk1.4.0...
I'm running as Paul (i.e. not as root or Postgres)...
"Paul" is a legit. database which Paul owns...
Browser is Netscape Version 4.78...

I use this code (non-critical functions deleted for simplicity's sake):

//BEGIN CODE SNIPPET

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.URL;
import java.sql.*;

public class PWEntry extends Applet implements ActionListener{
   private Connection db;
   private String url;
   private Button doItButton;
   private Button cancelButton;
   private Button resetButton;
   private TextField userIDField;
   private TextField passwordField;
   private TextField passwordCheckField;

   private Color bg = Color.gray;
   private Color textbg = Color.white;

   public void init(){
url = "jdbc:postgresql:Paul";
if(!(databaseSetup())){
   return;
}

makeLayout();
   }

   public void makeLayout(){
//Code removed for brevity
   }

   public boolean databaseSetup(){
System.out.println("databaseSetup");
try{
   Driver driver = (Driver)Class.forName("org.postgresql.Driver").newInstance();
   DriverManager.registerDriver(driver);
}
catch(Exception e){
   System.err.println("Exception: " + e.toString());
   return false;
}
System.out.println("databaseSetup successful");
return true;
   }

   public boolean databaseConnect(){
System.out.println("databaseConnect");
try{
   db = DriverManager.getConnection(url, "Paul", "");
}
catch (SQLException e){
   System.out.println("SQL Exception...");
   System.out.println(e.getMessage());
   System.out.println("...gonna give up.");
   return false;
}
System.out.println("databaseConnect successful");
return true;
   }

   public void start(){
System.out.println("start");
if(!(databaseConnect())){
   return;
}
   }

   public void stop(){
System.out.println("stop");
try{
   db.close();
}
catch(SQLException e){
}
   }

   public void actionPerformed(ActionEvent evt){
//Code removed for brevity
   }

   public boolean insertUser(){
//Code removed for brevity
   }

   public boolean validateInput(String uid, String pwd, String pwdChk){
//Code removed for brevity
   }

   public void reportError(String error){
//Code removed for brevity
   }

   //end of class
}

//END CODE SNIPPET

I get the following result when opening an html file which contains the above applet code:

//JAVA CONSOLE OUTPUT BEGINS

databaseSetup
databaseSetup successful
start
databaseConnect

SQL Exception...
Something unusual has occured to cause the driver to fail.  Please report this exception: Exception: java.lang.IllegalArgumentException: sun.io.CharToByteus-ascii
Stack Trace:

java.lang.IllegalArgumentException: sun.io.ChartToByteus-ascii
at sun.io.CharToByteConverter.getConverter(CharToByteConverter.java:99)
at java.lang.String.getBytes(String.java:544)
at org.postgresql.core.Encoding.isAvailable(Encoding.java:212)
at org.postgresql.core.Encoding.encodingForDatabaseEncoding(Encoding.java:106)
* at org.postgresql.core.Encoding.getEncoding(Encoding.java:88)
at org.postgresql.Connection.openConnection(Connection.java:324)
at org.postgresql.Driver.connect(Driver.java:149)
at java.sql.DriverManager.getConnection(DriverManager.java:90)
at java.sql.DriverManager.getConnection(DriverManager.java:132)
at PWEntry.databaseConnect(PWEntry.java:107)
at PWEntry.start(PWEntry.java:121)
at netscape.applet.DerivedAppletFrame$StartAppletEvent.dispatch(DerivedAppletFrame.java:640)
at java.awt.EventDispatchThread$EventPump.dispatchEvents(EventDispatchThread.java:81)
at java.awt.EventDispatchThread.run(EventDispatchThread.jav:135)
at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(DerivedAppletFrame.java:911)
End of Stack Trace

...gonna give up

//JAVA CONSOLE OUTPUT ENDS

Note that this code worked under Red Hat 6.1/Postgresql 7.2/pgjdbc1.jar.  I upgraded to RedHat 7.2, so my suspicion is that I fooed some setup parameter along the way, but which/what/where?  Any help would be gratefully accepted.