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 5A2A69FA2D4 for ; Thu, 14 Sep 2006 14:12:02 -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 69363-09 for ; Thu, 14 Sep 2006 17:11:56 +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 E224A9FA170 for ; Thu, 14 Sep 2006 14:11:54 -0300 (ADT) Received: (qmail invoked by alias); 14 Sep 2006 17:11:52 -0000 Received: from h81172159094.kund.kommunicera.umea.se (HELO chris) [81.172.159.94] by mail.gmx.net (mp020) with SMTP; 14 Sep 2006 19:11:52 +0200 X-Authenticated: #11617802 Message-ID: <001b01c6d820$e51157f0$5e9fac51@chris> From: "Christopher Bruhn" To: Subject: Problem with Java-SQL connection, postgresql.conf file Date: Thu, 14 Sep 2006 19:12:01 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0018_01C6D831.A84B6BB0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.631 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, HTML_40_50, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200609/54 X-Sequence-Number: 15772 This is a multi-part message in MIME format. ------=_NextPart_000_0018_01C6D831.A84B6BB0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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=20 (Project -> Properties -> Libraries -> added=20 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=20 (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)).=20 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 =3D=3D null) {=20 worker =3D new Thread(this); worker.start(); } } =20 public void run() { String url =3D "jdbc:postgresql://localhost/"; =20 try { Class.forName("org.postgresql.Driver"); } catch(Exception ex) { setError("Can't find Database driver class: " + ex); return; } try { Connection con =3D DriverManager.getConnection(url, rightuser, rightpassword); Statement stmt =3D con.createStatement(); stmt.executeUpdate(createTableCoffees); =20 stmt.close(); con.close(); } catch(SQLException ex) { setError("SQLException: " + ex); } } =20 } //////////////////////////// ... 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=F6hnliches ist = passiert,=20 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 =3D 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? Thank you very much for your help! With kind regards, Christopher Bruhn ------=_NextPart_000_0018_01C6D831.A84B6BB0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hallo,
 
I want to establish a connection to an = SQL Database=20 from a
Java Applet which is situated on the same server. I used=20 the
interface postgresql-8.2dev-503.jdbc3.jar. I use
NetBeans IDE = 5.0 (Sum=20 Microsystems) for the development of
Java Code. I copied=20 postgresql-8.2dev-503.jdbc3.jar into the
build/classes folder of the = project=20 containing the Applet
and made it accessible for Compile and Run as a = Library=20 of
the project
(Project -> Properties -> Libraries -> = added=20
postgresql-8.2dev-503.jdbc3.jar to Run and Compile). I also
added = postgresql-8.2dev-503.jdbc3.jar as a driver
(Runtime -> Databases = ->=20 Drivers -> Add Driver -> PostgreSQL
(v7.0 and later) is=20 accessible).
Moreover I unpacked the jar file into the build/classes=20 folder
and uploaded all files contained in the build folder to = the
server=20 (SERVER_SOFTWARE: Apache/2.0.54 (Fedora)).
 
I used essentially the following Java = code (Java=20 1.5.0_07)...
 
////////////////////////////
import=20 java.applet.Applet;
import java.sql.*;
 
public class O17 extends Applet = implements Runnable=20 {
    private Thread worker;
 
    public synchronized = void start()=20 {
 if (worker =3D=3D null)=20 { 
          &n= bsp;=20 worker =3D new Thread(this);
    =20 worker.start();
 }
    }
    =
    public void run() {
 String url =3D=20 "jdbc:postgresql://localhost/<DB>";
  
 try=20 {
     = Class.forName("org.postgresql.Driver");
 }=20 catch(Exception ex) {
     setError("Can't find = Database=20 driver class: " + ex);
    =20 return;
 }
 
 try {
     = Connection=20 con =3D=20 DriverManager.getConnection(url,
      r= ightuser,=20 rightpassword);
     Statement stmt =3D=20 con.createStatement();
    =20 stmt.executeUpdate(createTableCoffees);
    =20
     stmt.close();
    =20 con.close();
 
 } catch(SQLException ex)=20 {
     setError("SQLException: " +=20 ex);
 }
    } =20
}
////////////////////////////
 
... and different variations of the url = which=20 produced the following error codes:
 
jdbc:postgresql://localhost:5432/<DB>
jdbc:postgresql:/= /localhost/<DB>
jdbc:postgresql://<DB>
->org.postgre= sql.util.PSQLException:=20 Etwas Ungew=F6hnliches ist passiert,
das den Treiber fehlschlagen liess. = Bitte teilen=20 Sie diesen Fehler mit.
 
jdbc:postgresql://molekuelkueche.de/usr_web593_1
->org.pos= tgresql.util.PSQLException:=20 Der Verbindungsversuch schlug fehl.
(SERVER_NAME =3D www.molekuelkueche.de)
 
Moreover I searched for the = postgresql.conf file=20 but I could not find it
among the files extracted from=20 postgresql-8.2dev-503.jdbc3.jar.
 
Can you tell me if I use the Driver in = a wrong way,=20 where I can find
the postgresql.conf file and if I need to make = changes in=20 this file?
 
Thank you very much for your = help!
With kind=20 regards,
Christopher Bruhn
------=_NextPart_000_0018_01C6D831.A84B6BB0--