Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

beginner on JDBC. problem to connect database postgreSQL

843854Jun 25 2003 — edited Jun 26 2003
hi 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)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2003
Added on Jun 25 2003
5 comments
614 views