pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mikael Hammarin <mikael.hammarin@dc.etx.ericsson.se>
To: 'yangsu@flash.cs.iastate.edu' <yangsu@flash.cs.iastate.edu>
To: 'pgsql-interfaces@postgreSQL.org' <pgsql-interfaces@postgreSQL.org>
Subject: RE: [INTERFACES] simple JDBC --> can't get started
Date: Mon, 27 Jul 1998 08:35:05 +0200
Message-ID: <C17EAABE11FAD1119CC80060B087985524CC@CLETX08> (raw)

I'd guess you probably haven't started "postmaster" with -i,
which means it runs only through unix local domain sockets.

Check "man postmaster" for more info.

Cheers
//Mike

> -----Original Message-----
> From: Yang Su [mailto:yangsu@inkle.cs.iastate.edu]
> Sent: Monday, July 27, 1998 7:16 AM
> To: pgsql-interfaces@postgreSQL.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());
>         }
>    }
> 
> }
> 
> 
> 
> 



view thread (5+ messages)  latest in thread

Message-ID: <C17EAABE11FAD1119CC80060B087985524CC@CLETX08>
Permalink:  ../C17EAABE11FAD1119CC80060B087985524CC@CLETX08/
Also on:    postgresql.org/message-id/C17EAABE11FAD1119CC80060B087985524CC@CLETX08

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: mikael.hammarin@dc.etx.ericsson.se, yangsu@flash.cs.iastate.edu
  Subject: RE: [INTERFACES] simple JDBC --> can't get started
  In-Reply-To: <C17EAABE11FAD1119CC80060B087985524CC@CLETX08>

* 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