ya puse el driver en la carpeta ext y este es mi fragmento de codigo para comprobar si conecta a mi postgresql, pero me da una excepcion
Cita:
y me da esta excepcionpublic class PruebaPostgres {
ResultSet res=null;
String consulta="";
public PruebaPostgres() {
try
{
Class.forName("org.postgresql.Driver").newInstance ();
Connection c=DriverManager.getConnection("jdbc:postgresql://localhost/basedatos","sozo",".sozo");
}
catch (Exception e)
{
e.printStackTrace();
}
}
ResultSet res=null;
String consulta="";
public PruebaPostgres() {
try
{
Class.forName("org.postgresql.Driver").newInstance ();
Connection c=DriverManager.getConnection("jdbc:postgresql://localhost/basedatos","sozo",".sozo");
}
catch (Exception e)
{
e.printStackTrace();
}
}
Cita:
en q estoy fallando ?org.postgresql.util.PSQLException: El intento de conexi¾n fall¾.
Exception: java.net.UnknownHostException: localhost
Stack Trace:
java.net.UnknownHostException: localhost
at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:366)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:178)
at org.postgresql.core.PGStream.<init>(PGStream.java: 58)
at org.postgresql.core.v3.ConnectionFactoryImpl.openC onnectionImpl(Conne
ctionFactoryImpl.java:77)
at org.postgresql.core.ConnectionFactory.openConnecti on(ConnectionFactor
y.java:65)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init >(AbstractJdbc2Conn
ection.java:117)
at org.postgresql.jdbc2.Jdbc2Connection.<init>(Jdbc2C onnection.java:24)
at org.postgresql.Driver.connect(Driver.java:235)
at java.sql.DriverManager.getConnection(DriverManager .java:525)
at java.sql.DriverManager.getConnection(DriverManager .java:171)
at PruebaPostgres.<init>(PruebaPostgres.java:25)
at PruebaPostgres.main(PruebaPostgres.java:70)
End of Stack Trace
at org.postgresql.core.v3.ConnectionFactoryImpl.openC onnectionImpl(Conne
ctionFactoryImpl.java:136)
at org.postgresql.core.ConnectionFactory.openConnecti on(ConnectionFactor
y.java:65)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init >(AbstractJdbc2Conn
ection.java:117)
at org.postgresql.jdbc2.Jdbc2Connection.<init>(Jdbc2C onnection.java:24)
at org.postgresql.Driver.connect(Driver.java:235)
at java.sql.DriverManager.getConnection(DriverManager .java:525)
at java.sql.DriverManager.getConnection(DriverManager .java:171)
at PruebaPostgres.<init>(PruebaPostgres.java:25)
at PruebaPostgres.main(PruebaPostgres.java:70)
Press any key to continue...
Exception: java.net.UnknownHostException: localhost
Stack Trace:
java.net.UnknownHostException: localhost
at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:366)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:178)
at org.postgresql.core.PGStream.<init>(PGStream.java: 58)
at org.postgresql.core.v3.ConnectionFactoryImpl.openC onnectionImpl(Conne
ctionFactoryImpl.java:77)
at org.postgresql.core.ConnectionFactory.openConnecti on(ConnectionFactor
y.java:65)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init >(AbstractJdbc2Conn
ection.java:117)
at org.postgresql.jdbc2.Jdbc2Connection.<init>(Jdbc2C onnection.java:24)
at org.postgresql.Driver.connect(Driver.java:235)
at java.sql.DriverManager.getConnection(DriverManager .java:525)
at java.sql.DriverManager.getConnection(DriverManager .java:171)
at PruebaPostgres.<init>(PruebaPostgres.java:25)
at PruebaPostgres.main(PruebaPostgres.java:70)
End of Stack Trace
at org.postgresql.core.v3.ConnectionFactoryImpl.openC onnectionImpl(Conne
ctionFactoryImpl.java:136)
at org.postgresql.core.ConnectionFactory.openConnecti on(ConnectionFactor
y.java:65)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init >(AbstractJdbc2Conn
ection.java:117)
at org.postgresql.jdbc2.Jdbc2Connection.<init>(Jdbc2C onnection.java:24)
at org.postgresql.Driver.connect(Driver.java:235)
at java.sql.DriverManager.getConnection(DriverManager .java:525)
at java.sql.DriverManager.getConnection(DriverManager .java:171)
at PruebaPostgres.<init>(PruebaPostgres.java:25)
at PruebaPostgres.main(PruebaPostgres.java:70)
Press any key to continue...
el postgresql 8 q instale venia con el pgadmin y este es mi servidor que tengo dentro
y la contraseña para entrar a este servidor es .sozo