Обсуждение: Unable to connect to database

Поиск
Список
Период
Сортировка

Unable to connect to database

От
Peter Rogers
Дата:
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

RE: Unable to connect to database

От
Whitney Hunter
Дата:
Peter,

I believe that the url format is "jdbc.postgresql://<host>/<database>". This
could be the problem.

Whitney

-----Original Message-----
From: Peter Rogers [mailto:peterarogers@earthlink.net]
Sent: Friday, August 17, 2001 1: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)

RE: Unable to connect to database

От
"Dave Cramer"
Дата:
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)



Re: Unable to connect to database

От
Liam Stewart
Дата:
On Fri, Aug 17, 2001 at 11:00:40AM -0700, Whitney Hunter wrote:

> I believe that the url format is "jdbc.postgresql://<host>/<database>". This
> could be the problem.

Nope, that isn't the problem. The url format is correct. (assuming of
course that the database that Peter is connecting to is running on his
computer on port 5432.)

> 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

Your code looks alright - there are no errors/... there. Try a newer
JDBC driver (from CVS). Other than that, the problem could be your JVM.
Which one are you using exactly?

Liam

--
Liam Stewart :: Red Hat Canada, Ltd. :: liams@redhat.com

Re: Unable to connect to database

От
Rene Pijlman
Дата:
On Fri, 17 Aug 2001 15:11:57 -0400, you wrote:
>Try a newer JDBC driver (from CVS).

Standard support answer #1 :-)

The driver is AFAIK 100% pure Java. I don't think there is a fix
for a JVM segmentation fault in the driver, do you?

>the problem could be your JVM

That's better advice :-)

Seriously, I don't think we should be telling people to upgrade
to the latest CVS version, unless there is a good and specific
reason to assume that this might solve the problem.

Regards,
René Pijlman

Re: Unable to connect to database

От
Peter Rogers
Дата:
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@earthlink.net]
> Sent: Friday, August 17, 2001 2: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)

RE: Unable to connect to database

От
"Michael Ansley (UK)"
Дата:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Although, even if the problem is sorted, it appears that you have an
erratic JVM problem.  Having -i off should not cause your JVM to dump
core.  On RH7.1 I know that I have to set LD_ASSUME_KERNEL=2.2.5 in
my java script, as not having it causes quite a few *erratic*
problems.  You might want to check whether or not you need this
(Linux only, I think, and although I picked it up through the RH7.1
README (and some help from Trond ;-), I'm sure that there are other
distributions that require it, and it's possible that recent BSDs
using a Linux JVM might also require it).

Cheers...

MikeA

>> -----Original Message-----
>> From: Peter Rogers [mailto:peterarogers@earthlink.net]
>> Sent: 19 August 2001 22:51
>> To: Lucas, Fred
>> Cc: pgsql-jdbc@postgresql.org
>> Subject: Re: [JDBC] Unable to connect to database
>>
>>
>> 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@earthlink.net]
>> > Sent: Friday, August 17, 2001 2: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)
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 4: Don't 'kill -9' the postmaster
>>

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBO4DeZXympNV/C086EQLJ3QCcDArs5YV+xl8pslpcG/9nMW3ica4AnRs1
MLA5a0k5SCEeNdmyVMcKeuA6
=brF8
-----END PGP SIGNATURE-----

_________________________________________________________________________
This e-mail and any attachments are confidential and may also be privileged and/or copyright
material of Intec Telecom Systems PLC (or its affiliated companies). If you are not an
intended or authorised recipient of this e-mail or have received it in error, please delete
it immediately and notify the sender by e-mail. In such a case, reading, reproducing,
printing or further dissemination of this e-mail is strictly prohibited and may be unlawful.
Intec Telecom Systems PLC. does not represent or warrant that an attachment hereto is free
from computer viruses or other defects. The opinions expressed in this e-mail and any
attachments may be those of the author and are not necessarily those of Intec Telecom
Systems PLC.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
__________________________________________________________________________

Re: Unable to connect to database

От
Steve Wampler
Дата:
> "Michael Ansley (UK)" wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Although, even if the problem is sorted, it appears that you have an
> erratic JVM problem.  Having -i off should not cause your JVM to dump
> core.  On RH7.1 I know that I have to set LD_ASSUME_KERNEL=2.2.5 in
> my java script, as not having it causes quite a few *erratic*
> problems.  You might want to check whether or not you need this
> (Linux only, I think, and although I picked it up through the RH7.1
> README (and some help from Trond ;-), I'm sure that there are other
> distributions that require it, and it's possible that recent BSDs
> using a Linux JVM might also require it).
>

I don't think the LD_ASSUME_KERNEL=2.2.5 is needed with Sun's JVMs
from 1.3.1rc2-build23 and later - only with earlier versions.

--
Steve Wampler-  SOLIS Project, National Solar Observatory
swampler@noao.edu