beginner on JDBC. problem to connect database postgreSQL
843854Jun 25 2003 — edited Jun 26 2003hi there everyone,
new to JDBC.
not sure, what's wrong with that.
I am using XP, postgreSQL 7.3.3 - the database is fine ( i can create a table via cygwin).
- i have downloaded the pgSQL jdbc driver also set the classpath.
thanks in advanc
===================================
import java.sql.*;
public class Example {
public static void main(String args[])
{
String userName="user1";
String password="whatever";
try
{
String url = "jdbc:postgresql:myDB";
Class.forName("org.postgresql.Driver");
Connection myConnection= DriverManager.getConnection(url,userName,password);
} catch ( java.lang.Exception ex){ ex.printStackTrace();}
}
}
===========================================================
Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:167)
at org.postgresql.Driver.connect(Driver.java:122)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:172)
at Example.main(Example.java:17)