Skip site navigation (1) Skip section navigation (2)

Re: Problem with Java-SQL connection, postgresql.conf file

From: Roland Walter <roland(dot)walter(dot)rwa(at)gmx(dot)net>
To: Christopher Bruhn <pandafisch(at)gmx(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Problem with Java-SQL connection, postgresql.conf file
Date: 2006-09-14 22:50:26
Message-ID: 4509DCB2.4050303@gmx.net (view raw or flat)
Thread:
Lists: pgsql-jdbc
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Christopher Bruhn schrieb:
> Hallo,
>  
> I want to establish a connection to an SQL Database from a
> Java Applet which is situated on the same server. I used the
> interface postgresql-8.2dev-503.jdbc3.jar. I use
> NetBeans IDE 5.0 (Sum Microsystems) for the development of
> Java Code. I copied postgresql-8.2dev-503.jdbc3.jar into the
> build/classes folder of the project containing the Applet
> and made it accessible for Compile and Run as a Library of
> the project
> (Project -> Properties -> Libraries -> added
> postgresql-8.2dev-503.jdbc3.jar to Run and Compile). I also
> added postgresql-8.2dev-503.jdbc3.jar as a driver
> (Runtime -> Databases -> Drivers -> Add Driver -> PostgreSQL
> (v7.0 and later) is accessible).
> Moreover I unpacked the jar file into the build/classes folder
> and uploaded all files contained in the build folder to the
> server (SERVER_SOFTWARE: Apache/2.0.54 (Fedora)).
>  
> I used essentially the following Java code (Java 1.5.0_07)...
>  
> ////////////////////////////
> import java.applet.Applet;
> import java.sql.*;
>  
> public class O17 extends Applet implements Runnable {
>     private Thread worker;
>  
>     public synchronized void start() {
>  if (worker == null) { 
>             worker = new Thread(this);
>      worker.start();
>  }
>     }
>    
>     public void run() {
>  String url = "jdbc:postgresql://localhost/<DB>";
>   
>  try {
>      Class.forName("org.postgresql.Driver");
>  } catch(Exception ex) {
>      setError("Can't find Database driver class: " + ex);
>      return;
>  }
>  
>  try {
>      Connection con = DriverManager.getConnection(url,
>       rightuser, rightpassword);
>      Statement stmt = con.createStatement();
>      stmt.executeUpdate(createTableCoffees);
>     
>      stmt.close();
>      con.close();
>  
>  } catch(SQLException ex) {
>      setError("SQLException: " + ex);
>  }
>     } 
> }
> ////////////////////////////
>  
> ... and different variations of the url which produced the following
> error codes:
>  
> jdbc:postgresql://localhost:5432/<DB>
> jdbc:postgresql://localhost/<DB>
> jdbc:postgresql://<DB>
> ->org.postgresql.util.PSQLException: Etwas Ungewöhnliches ist passiert,
> das den Treiber fehlschlagen liess. Bitte teilen Sie diesen Fehler mit.
>  
> jdbc:postgresql://molekuelkueche.de/usr_web593_1
> ->org.postgresql.util.PSQLException: Der Verbindungsversuch schlug fehl.
> (SERVER_NAME = www.molekuelkueche.de <http://www.molekuelkueche.de>)
>  
> Moreover I searched for the postgresql.conf file but I could not find it
> among the files extracted from postgresql-8.2dev-503.jdbc3.jar.
>  
> Can you tell me if I use the Driver in a wrong way, where I can find
> the postgresql.conf file and if I need to make changes in this file?
>  

It looks as if your database is not correct configured for a connection
over tcp/ip. The file postgresql.conf is in the directory of the
database. There you have to comment out the line with the
'listen_adresses' and give it the correct parameters. If that looks
correct you have to configure the access to the database in the file
pg_hba.conf in the same directory. Consider the handbook for the correct
parameters.

Regards,
Roland.

- --
Dipl.-Phys. Roland Walter
mailto: roland (dot) walter (dot) rwa (at) gmx (dot) net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFFCdyyxoOEAkary1ERAlxUAJ9DnGuNiS+UweU6ZC11FzsyZsT5ZwCcDIaE
hSzchqLHij86uKh2iBxayc0=
=cuI5
-----END PGP SIGNATURE-----

In response to

pgsql-jdbc by date

Next:From: Albert CardonaDate: 2006-09-15 00:26:21
Subject: Re: about monitoring the input stream
Previous:From: Christopher BruhnDate: 2006-09-14 17:12:01
Subject: Problem with Java-SQL connection, postgresql.conf file

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group