Re: Unable to connect to database

From: Peter Rogers <peterarogers(at)earthlink(dot)net>
To: "Lucas, Fred" <fred(dot)lucas(at)ps(dot)bellhowell(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Unable to connect to database
Date: 2001-08-19 21:51:29
Message-ID: 3B8034E1.7BF600F0@earthlink.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi Fred--

Thanks -- that was it! I can now connect to the database.

Also thanks to everyone else to responded to my post.

--Pete Rogers

> "Lucas, Fred" wrote:
>
> Peter,
> The JDBC requires TCP/IP sockect to connect to Postgresql, Are you
> running the postmaster with the -i switch? You may have this already
> setup. I just wanted to pass it along
>
> Fred
>
> -----Original Message-----
> From: Peter Rogers [mailto:peterarogers(at)earthlink(dot)net]
> Sent: Friday, August 17, 2001 2:27 PM
> To: pgsql-jdbc(at)postgresql(dot)org
> Subject: [JDBC] Unable to connect to database
>
> Please have mercy on this poor beginner!
>
> I am totally new to both postgresql and jdbc, so I'm probably
> committing
> some very basic error, but I am unable to make a connection to my
> database via jdbc. I am using postgresql 7.1.2 which seems to be
> running OK (under Suse Linux 7.1); at least I can run the sample
> interactive scripts with pqsl. I built and installed jdbc according
> to
> the instructions in the readme file, and I am using Java 1.3. I used
> "createdb" to create my own database "petesdb" with username
> "progers".
> However, when I run the small piece of code below, the driver gets
> registered, but getConnection fails with a segmentation fault.
>
> import java.sql.*;
> import java.lang.reflect.*;
> import java.io.*;
> import java.util.*;
>
> public class TestDb
> {
>
> public static void main(String args[])
> {
> Connection db; // The connection to the database
> Statement st; // Our statement to run queries with
>
> try
> {
> // This line outputs debug information to stderr
> DriverManager.setLogStream(System.err);
>
> Class.forName("org.postgresql.Driver");
> System.out.println("Db driver OK");
>
> // Connect to database
> String url = "jdbc:postgresql:petesdb";
> String usr = "progers";
> String pwd = "petesdb_pwd";
> System.out.println("Connecting to Database URL = " + url);
> db = DriverManager.getConnection(url, usr, pwd);
> System.out.println("Db connection OK");
>
> }
> catch(Exception e)
> {
> // your error handling code goes here
> System.out.println("Hey! no db driver or no db connection");
>
> }
> }
> }
>
> The console output is as follows:
>
> DriverManager.initialize: jdbc.drivers = null
> JDBC DriverManager initialized
> registerDriver:
> driver[className=org.postgresql.Driver,org(dot)postgresql(dot)Driver(at)4b222f]
> Db driver OK
> Connecting to Database URL = jdbc:postgresql:petesdb
> DriverManager.getConnection("jdbc:postgresql:petesdb")
> trying
> driver[className=org.postgresql.Driver,org(dot)postgresql(dot)Driver(at)4b222f]
> Segmentation fault
>
> My thanks for any help anyone can offer.
>
> --Pete Rogers
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to
> majordomo(at)postgresql(dot)org)

Browse pgsql-jdbc by date

  From Date Subject
Next Message RaviShankar K 2001-08-20 06:45:34 Problem while using result set
Previous Message Jason Orendorff 2001-08-18 03:55:13 Bad BigDecimal