Skip site navigation (1) Skip section navigation (2)

RE: [INTERFACES] simple JDBC --> can't get started

From: Michael Yeung <michaely(at)alphanet(dot)net(dot)au>
To: "'yangsu(at)flash(dot)cs(dot)iastate(dot)edu'" <yangsu(at)flash(dot)cs(dot)iastate(dot)edu>
Cc: "'Interfaces of Postgres'" <pgsql-interfaces(at)postgreSQL(dot)org>
Subject: RE: [INTERFACES] simple JDBC --> can't get started
Date: 1998-07-27 05:35:13
Message-ID: 01BDB974.267998D0@wynyard.alphanet.net.au (view raw or flat)
Thread:
Lists: pgsql-interfaces
HI,

What have u entered for your password entry.

For most JDBC driver, you have to enter the password for the user that connected to the dB Server.

You haven't enter the password, have you ?

cheers,
Michael
-----Original Message-----
From:	Yang Su [SMTP:yangsu(at)inkle(dot)cs(dot)iastate(dot)edu]
Sent:	Monday, July 27, 1998 3:16 PM
To:	pgsql-interfaces(at)postgreSQL(dot)org
Subject:	[INTERFACES] simple JDBC --> can't get started


I have a simple test.java which tries to connect to a database I have
created, my user name is "yangsu" which is created by "createuser yangsu"
My db_hba.conf has only the following lines:

local        all                                         trust
host         all         127.0.0.1     255.255.255.255   trust     
host         all         129.186.68.160  255.255.255.255 trust

My machine name is inkle.cs.iastate.edu(ip 129.186.68.160), my execution
of "java test" yields:

Class.forName OK!
java.sql.SQLException: Connection failed: java.net.ConnectException: Connection refused

What is the error?(what causes the error?) Thanks for any suggestions.

yang
http://www.cs.iastate.edu/~yangsu/


Following is the test.java:

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

public class test{

   public static void main(String args[]){
        try{
                Class.forName("postgresql.Driver");
                System.out.println("Class.forName OK!");

                String url="jdbc:postgresql://inkle.cs.iastate.edu/test";
                String usr="yangsu";
                String pwd="";

                Connection db = DriverManager.getConnection(url, usr, pwd);
                if(db != null){
                        System.out.println("Connected to db");
                }else{
                        System.out.println("Can't connect to db");
                }

                Statement st = db.createStatement();
                ResultSet rs = st.executeQuery("select * from classmate");

                while(rs.next()){
                        System.out.println(rs.getString("name"));
                        System.out.println(rs.getBoolean("sex"));
                        System.out.println(rs.getInt("age"));
                }
        }catch(Exception e){
                System.out.println(e.toString());
        }
   }

}




pgsql-interfaces by date

Next:From: Mikael HammarinDate: 1998-07-27 06:35:05
Subject: RE: [INTERFACES] simple JDBC --> can't get started
Previous:From: Yang SuDate: 1998-07-27 05:15:33
Subject: simple JDBC --> can't get started

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group