jdbc + postgres - Mailing list pgsql-general

From Przemyslaw Bak
Subject jdbc + postgres
Date
Msg-id Pine.SV4.3.96.981020172208.29277B-100000@STORE3
Whole thread Raw
Responses Re: [GENERAL] jdbc + postgres
List pgsql-general
Hello,

I have following program:

-----------------------  CUT  ------------------------
import java.net.URL;
import java.sql.*;

....

    String url = "jdbc:postgresql://localhost/store3";
    //String url = "jdbc:postgresql:store3";
    Connection db;
    Statement st;

TillInfo () {
    try {
        System.err.println ( "Loading driver ..." );
        Class.forName ("postgresql.Driver");
    } catch (java.lang.ClassNotFoundException e) {
        System.err.print ("ClassNotFoundException:");
        System.err.println (e.getMessage());
    }

    try {
        System.err.println ( "Connecting ..." );
        db = DriverManager.getConnection (url,"przemol","przemol");
        System.err.println ( "Preparing statement ..." );
        st = db.createStatement ();
        System.err.println ( "Executing query ..." );
        ResultSet rs = st.executeQuery (query);
        if (rs != null) {
            ....
        }
        st.close ();
        db.close ();
    } catch (SQLException ex) {
        System.err.println ( "SQLState:" + ex.getSQLState() );
        System.err.println ( "Message:" + ex.getMessage() );
        System.err.println ( "Vendor:" + ex.getErrorCode() );
    }
}

------------------ CUT ------------------

While running I have message:

Loading driver ...
Connecting ...
SQLState:null
Message:Connection failed: java.net.ConnectException: Connection refused
Vendor:0
Exception occurred during event dispatching:
java.lang.ArithmeticException: / by zero
    at PanelChart.paint(PanelChart.java:11)
    at java.awt.Component.dispatchEventImpl(Component.java:1401)
    at java.awt.Component.dispatchEvent(Component.java:1382)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)


Could you tell me whats wrong with my program ?
Do I have to change sources ? If so can you tell me how ?
I use jdbc driver from postgres 6.3.2 sources and jdk 1.1.3.
Of course postgres is running :))


przemol


pgsql-general by date:

Previous
From: Nagy Zoltan
Date:
Subject: 8k tuple limit
Next
From: Peter T Mount
Date:
Subject: Re: [GENERAL] jdbc + postgres