pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PaulU71555@aol.com
To: pgsql-jdbc@postgresql.org
Subject: Connection problems
Date: Sun, 28 Apr 2002 14:44:33 EDT
Message-ID: <9.273c0891.29fd9d11@aol.com> (raw)

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(DerivedAppletFram

e.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(DerivedApplet

Frame.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.

view thread (3+ messages)  latest in thread

Message-ID: <9.273c0891.29fd9d11@aol.com>
Permalink:  ../9.273c0891.29fd9d11@aol.com/
Also on:    postgresql.org/message-id/9.273c0891.29fd9d11@aol.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: PaulU71555@aol.com
  Subject: Re: Connection problems
  In-Reply-To: <9.273c0891.29fd9d11@aol.com>
  References: <9.273c0891.29fd9d11@aol.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox