RE: Unable to connect to database - Mailing list pgsql-jdbc

From Dave Cramer
Subject RE: Unable to connect to database
Date
Msg-id 001e01c12745$6090bed0$c201a8c0@inspiron
Whole thread Raw
In response to Unable to connect to database  (Peter Rogers <peterarogers@earthlink.net>)
List pgsql-jdbc
Peter,

Do you have any other problems running java on this machine. The only
reason you should ever get a segmentation fault with java is if the jvm
is buggy.

What jvm are you using. I know there are issues running sun's jvm on
newer distributions.

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Peter Rogers
Sent: August 17, 2001 4:27 PM
To: pgsql-jdbc@postgresql.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.postgresql.Driver@4b222f]
Db driver OK
Connecting to Database URL = jdbc:postgresql:petesdb
DriverManager.getConnection("jdbc:postgresql:petesdb")
    trying
driver[className=org.postgresql.Driver,org.postgresql.Driver@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@postgresql.org)



pgsql-jdbc by date:

Previous
From: Whitney Hunter
Date:
Subject: RE: Unable to connect to database
Next
From: Liam Stewart
Date:
Subject: Re: Unable to connect to database