pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christopher Bruhn <pandafisch@gmx.de>
To: pgsql-jdbc@postgresql.org
Subject: Problem with Java-SQL connection, postgresql.conf file
Date: Thu, 14 Sep 2006 19:12:01 +0200
Message-ID: <001b01c6d820$e51157f0$5e9fac51@chris> (raw)

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)

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

view thread (3+ messages)  latest in thread

Message-ID: <001b01c6d820$e51157f0$5e9fac51@chris>
Permalink:  ../001b01c6d820$e51157f0$5e9fac51@chris/
Also on:    postgresql.org/message-id/001b01c6d820$e51157f0$5e9fac51@chris

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pandafisch@gmx.de
  Subject: Re: Problem with Java-SQL connection, postgresql.conf file
  In-Reply-To: <001b01c6d820$e51157f0$5e9fac51@chris>
  References: <001b01c6d820$e51157f0$5e9fac51@chris>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox