X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 9E93C9FA0B9 for ; Thu, 14 Sep 2006 19:50:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 77130-05 for ; Thu, 14 Sep 2006 22:50:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) by postgresql.org (Postfix) with SMTP id C2D189F9EEF for ; Thu, 14 Sep 2006 19:50:35 -0300 (ADT) Received: (qmail invoked by alias); 14 Sep 2006 22:50:34 -0000 Received: from xdsl-213-196-246-119.netcologne.de (EHLO [192.168.3.10]) [213.196.246.119] by mail.gmx.net (mp033) with SMTP; 15 Sep 2006 00:50:34 +0200 X-Authenticated: #2870507 Message-ID: <4509DCB2.4050303@gmx.net> Date: Fri, 15 Sep 2006 00:50:26 +0200 From: Roland Walter User-Agent: Thunderbird 1.5.0.5 (X11/20060725) MIME-Version: 1.0 To: Christopher Bruhn CC: pgsql-jdbc@postgresql.org Subject: Re: Problem with Java-SQL connection, postgresql.conf file References: <001b01c6d820$e51157f0$5e9fac51@chris> In-Reply-To: <001b01c6d820$e51157f0$5e9fac51@chris> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.134 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, SPF_PASS X-Spam-Level: X-Archive-Number: 200609/55 X-Sequence-Number: 15773 -----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/"; > > 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/ > jdbc:postgresql://localhost/ > jdbc:postgresql:// > ->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 ) > > 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-----