From: | "LINA M(dot) GARCIA HENAO" <limagarc(at)univalle(dot)edu(dot)co> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | problem connecting to jdbc |
Date: | 2003-11-06 01:25:01 |
Message-ID: | Pine.BSF.4.58.0311052020110.84441@libertad.univalle.edu.co |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)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(at)yahoo(dot)com *
Universidad Del Valle *
************************************************
From | Date | Subject | |
---|---|---|---|
Next Message | James Robinson | 2003-11-06 19:13:15 | "Fix" for INT8 literals being parsed as INT4 disqualifying index scan problem in JBoss ... |
Previous Message | Carlos Ho Shih Ning | 2003-11-05 19:54:33 | PostGIS: Type 'geometry'does does not exist: Attachment |