problem connecting to jdbc - Mailing list pgsql-jdbc

From LINA M. GARCIA HENAO
Subject problem connecting to jdbc
Date
Msg-id Pine.BSF.4.58.0311052020110.84441@libertad.univalle.edu.co
Whole thread Raw
Responses Re: problem connecting to jdbc  ("Nick Fankhauser" <nickf@ontko.com>)
List pgsql-jdbc
Hello i have the following java code

public class BD
{
  Connection db;    // The connection to the database
  Statement  st;    // Our statement to run queries with

  public BD()
  {

  }

 public Connection getConexion(String url, String usr, String pwd)
  {
    try{
    Class.forName("org.postgresql.Driver");
     }catch(ClassNotFoundException e)
    {
      System.out.print("1"+e);
    }

    try{
     db = DriverManager.getConnection(url, usr, pwd);
     }catch(SQLException e)
     {
      System.out.print("2"+e);
     }
    return db;

  }
}

and i have the following class that uses BD.class

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import ConectarBd.BD;


public class Prueba {
          public static void main(String[] argv) throws Exception
          {
                   BD conectar=new  BD();

                     Connection con =
conectar.getConexion("jdbc:postgresql://localhost/","lina","hello");

                     //Statement stm =
con.createStatement();
                    // ResultSet rs =
stm.executeQuery("select * from datosclinicos");

          }
}

and the both compile with no problem but when i excecute the class Prueba
i get the following:

[root@lmgh Herramientas]# java Prueba
2The connection attempt failed because Exception: java.io.IOException:
Connection refused
Stack Trace:

java.io.IOException: Connection refused
        at
java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:native)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:57)
        at java.net.Socket.<init>(Socket.java:54)
        at java.net.Socket.<init>(Socket.java:29)
        at org.postgresql.PG_Stream.<init>(PG_Stream.java:38)
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:160)
        at org.postgresql.Driver.connect(Driver.java:122)
        at java.sql.DriverManager.getConnection(DriverManager.java:63)
        at java.sql.DriverManager.getConnection(DriverManager.java:51)
        at ConectarBd.BD.getConexion(BD.java:42)
        at Prueba.main(Prueba.java:13)
End of Stack Trace

PLEASE HELP ME ..what am i doing wrong??

--
/***********************************************
 -    -              -    -      ---  --  --   *
| |  (_)_ _  __ _   |  \/  |    / __| | || |   *
| |__| | ' \/ _` |  | |\/| |_  | (_ |_| __ |_  *
|____|_|_||_\__,_|  |_|  |_(_)  \___(_)_||_(_) *
          Lina  Maria  Garcia  Henao           *
     ESTUDIANTE DE INGENIERIA DE SISTEMAS      *
             limagarc@yahoo.com                *
           Universidad Del Valle               *
************************************************

pgsql-jdbc by date:

Previous
From: Binh Nguyen Thanh
Date:
Subject: Question
Next
From: "Jan Slivka"
Date:
Subject: ResultSetMetaData.isNullable() returns always unknown status