Thread: Failed Connection (again)

Failed Connection (again)

From
Gonzo Programming
Date:
Having HUGE troubles connecting to a pgDatabase. I have been struggling with this for 3 days now...

I Have scoured the docs, and this jdbc list archive without success. I would Love to find a mentor who might spend a
bitof time getting me past this obstacle. Yes, I am new to java. :( 

-----------
The Details,

1) I have pgSQL running on RedHat7.1 and have connected to it with pgAccess and created a few tables and populated them
withsome data. 

2) I have installed pgAdmin on a NT machine on the network and accessed the data on the Linux machine described above.

3) I am developing a simple program on the NT machine and I have copied some example code from a JavaTutorial and
compiledand made it work to access a MSAccess db locally on the on the NT machine running JDK1.3 

4.) I have read the Docs written by Peter Mount and have modified the code in what seem reasoable ways to access the
pgDatabase...all to no avail.  

4a) I have renamed jdb7.0-1.1.jar to postgresql.jar and then copied that .jar file into as many places as seems
reasonableand not so reasonable(yes I have copies all over the place at present), yet still get this error at run time. 

H:\JavaLessons\ch18\fig18_24>java TableDisplayPG1
Failed to load JDBC/ODBC driver.
java.lang.ClassNotFoundException: org.postgresql.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
       and about 10 more lines of errors...

--------

Is there someone with a big heart and brain who would spend some time helping me get this working... I suspect once I
doI'll be sailing(yeah right). Maybe set up and instant message chat or something to work it through... The source code
isbelow.  Thanks to whom ever has some time. 

Gonzo feeling like a bozo!

-----------
Source code
*************
// This works
*************
// The URL specifying the Books database to which
// this program connects using JDBC to connect to a
// Microsoft ODBC database.
   String url = "jdbc:odbc:Books";
   String username = "anonymous";
   String password = "guest";

*************
// This DOES NOT work!!
*************
// The URL specifying the test database to which
// this program connects using JDBC to connect to a
// postgres database on the network somewhere.
   String url = "jdbc://10.0.0.15:5432/test";
   String username = "postgres";
   String password = "";

*************
// This works
*************
// Load the driver to allow connection to the database
   try {
      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
      connection = DriverManager.getConnection(
      url, username, password );
      }
   catch ( ClassNotFoundException cnfex ) {
      System.err.println(
         "Failed to load JDBC/ODBC driver." );
      cnfex.printStackTrace();
      System.exit( 1 );  // terminate program
*************
// This DOES NOT work!
*************
// Load the driver to allow connection to the database
   try {
      Class.forName("org.postgresql.Driver");
      connection = DriverManager.getConnection(
      url, username, password );
      }



Re: Failed Connection (again)

From
"Dave Cramer"
Date:
It would look like the url is wrong

it should look something like

"jdbc:postgresql://ebox2.sentricity.com/tickets"

note the "jdbc:postgresql" part
the "ebox2.sentricity.com" is the machine
the "tickets" is the db

my icq # is 14675561 if this doesn't work

Cheers,

Dave
----- Original Message -----
From: "Gonzo Programming"
<GonzoRock--at--Excite--dot--com@mta6.snfc21.pbi.net>
To: <pgsql-jdbc@postgresql.org>
Sent: Friday, June 08, 2001 1:03 PM
Subject: [JDBC] Failed Connection (again)


> Having HUGE troubles connecting to a pgDatabase. I have been struggling
with this for 3 days now...
>
> I Have scoured the docs, and this jdbc list archive without success. I
would Love to find a mentor who might spend a bit of time getting me past
this obstacle. Yes, I am new to java. :(
>
> -----------
> The Details,
>
> 1) I have pgSQL running on RedHat7.1 and have connected to it with
pgAccess and created a few tables and populated them with some data.
>
> 2) I have installed pgAdmin on a NT machine on the network and accessed
the data on the Linux machine described above.
>
> 3) I am developing a simple program on the NT machine and I have copied
some example code from a JavaTutorial and compiled and made it work to
access a MSAccess db locally on the on the NT machine running JDK1.3
>
> 4.) I have read the Docs written by Peter Mount and have modified the code
in what seem reasoable ways to access the pgDatabase ...all to no avail.
>
> 4a) I have renamed jdb7.0-1.1.jar to postgresql.jar and then copied that
.jar file into as many places as seems reasonable and not so reasonable(yes
I have copies all over the place at present), yet still get this error at
run time.
>
> H:\JavaLessons\ch18\fig18_24>java TableDisplayPG1
> Failed to load JDBC/ODBC driver.
> java.lang.ClassNotFoundException: org.postgresql.Driver
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>        and about 10 more lines of errors...
>
> --------
>
> Is there someone with a big heart and brain who would spend some time
helping me get this working... I suspect once I do I'll be sailing(yeah
right). Maybe set up and instant message chat or something to work it
through... The source code is below.  Thanks to whom ever has some time.
>
> Gonzo feeling like a bozo!
>
> -----------
> Source code
> *************
> // This works
> *************
> // The URL specifying the Books database to which
> // this program connects using JDBC to connect to a
> // Microsoft ODBC database.
>    String url = "jdbc:odbc:Books";
>    String username = "anonymous";
>    String password = "guest";
>
> *************
> // This DOES NOT work!!
> *************
> // The URL specifying the test database to which
> // this program connects using JDBC to connect to a
> // postgres database on the network somewhere.
>    String url = "jdbc://10.0.0.15:5432/test";
>    String username = "postgres";
>    String password = "";
>
> *************
> // This works
> *************
> // Load the driver to allow connection to the database
>    try {
>       Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
>       connection = DriverManager.getConnection(
>       url, username, password );
>       }
>    catch ( ClassNotFoundException cnfex ) {
>       System.err.println(
>          "Failed to load JDBC/ODBC driver." );
>       cnfex.printStackTrace();
>       System.exit( 1 );  // terminate program
> *************
> // This DOES NOT work!
> *************
> // Load the driver to allow connection to the database
>    try {
>       Class.forName("org.postgresql.Driver");
>       connection = DriverManager.getConnection(
>       url, username, password );
>       }
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
>


Re: Failed Connection (again)

From
Gonzo Programming
Date:
Oops, Yes, the url WAS wrong... however, correcting it has not made a difference... still getting the errors as
describedway below. 

The first error text is recognizable from the source code....
  catch (ClassNotFoundException cnfex)

The second... not so sure Where that comes from

At 10:51 AM 6/11/01 -0400, Dave Cramer wrote:
>It would look like the url is wrong
>
>it should look something like
>
>"jdbc:postgresql://ebox2.sentricity.com/tickets"
>
>note the "jdbc:postgresql" part
>the "ebox2.sentricity.com" is the machine
>the "tickets" is the db
>
>my icq # is 14675561 if this doesn't work
>
>Cheers,
>
>Dave
>----- Original Message -----
>From: "Gonzo Programming"
><GonzoRock--at--Excite--dot--com@mta6.snfc21.pbi.net>
>To: <pgsql-jdbc@postgresql.org>
>Sent: Friday, June 08, 2001 1:03 PM
>Subject: [JDBC] Failed Connection (again)
>
>
>> Having HUGE troubles connecting to a pgDatabase. I have been struggling
>with this for 3 days now...
>>
>> I Have scoured the docs, and this jdbc list archive without success. I
>would Love to find a mentor who might spend a bit of time getting me past
>this obstacle. Yes, I am new to java. :(
>>
>> -----------
>> The Details,
>>
>> 1) I have pgSQL running on RedHat7.1 and have connected to it with
>pgAccess and created a few tables and populated them with some data.
>>
>> 2) I have installed pgAdmin on a NT machine on the network and accessed
>the data on the Linux machine described above.
>>
>> 3) I am developing a simple program on the NT machine and I have copied
>some example code from a JavaTutorial and compiled and made it work to
>access a MSAccess db locally on the on the NT machine running JDK1.3
>>
>> 4.) I have read the Docs written by Peter Mount and have modified the code
>in what seem reasoable ways to access the pgDatabase ...all to no avail.
>>
>> 4a) I have renamed jdb7.0-1.1.jar to postgresql.jar and then copied that
>.jar file into as many places as seems reasonable and not so reasonable(yes
>I have copies all over the place at present), yet still get this error at
>run time.
>>
>> H:\JavaLessons\ch18\fig18_24>java TableDisplayPG1
>> Failed to load JDBC/ODBC driver.
>> java.lang.ClassNotFoundException: org.postgresql.Driver
>>     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>        and about 10 more lines of errors...
>>
>> --------
>>
>> Is there someone with a big heart and brain who would spend some time
>helping me get this working... I suspect once I do I'll be sailing(yeah
>right). Maybe set up and instant message chat or something to work it
>through... The source code is below.  Thanks to whom ever has some time.
>>
>> Gonzo feeling like a bozo!
>>
>> -----------
>> Source code
>> *************
>> // This works
>> *************
>> // The URL specifying the Books database to which
>> // this program connects using JDBC to connect to a
>> // Microsoft ODBC database.
>>    String url = "jdbc:odbc:Books";
>>    String username = "anonymous";
>>    String password = "guest";
>>
>> *************
>> // This DOES NOT work!!
>> *************
>> // The URL specifying the test database to which
>> // this program connects using JDBC to connect to a
>> // postgres database on the network somewhere.
>>    String url = "jdbc://10.0.0.15:5432/test";
>>    String username = "postgres";
>>    String password = "";
>>
>> *************
>> // This works
>> *************
>> // Load the driver to allow connection to the database
>>    try {
>>       Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
>>       connection = DriverManager.getConnection(
>>       url, username, password );
>>       }
>>    catch ( ClassNotFoundException cnfex ) {
>>       System.err.println(
>>          "Failed to load JDBC/ODBC driver." );
>>       cnfex.printStackTrace();
>>       System.exit( 1 );  // terminate program
>> *************
>> // This DOES NOT work!
>> *************
>> // Load the driver to allow connection to the database
>>    try {
>>       Class.forName("org.postgresql.Driver");
>>       connection = DriverManager.getConnection(
>>       url, username, password );
>>       }
>>
>>
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 5: Have you checked our extensive FAQ?
>>
>> http://www.postgresql.org/users-lounge/docs/faq.html
>>
>>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to majordomo@postgresql.org so that your
>message can get through to the mailing list cleanly
>

Re: Failed Connection (again)

From
"George Koras"
Date:
Forgive me for asking the obvious question, but does your CLASSPATH include
the pathname
of any of your .jar file copies? Should be the full pathname, not just the
path.

----- Original Message -----
From: Gonzo Programming
<GonzoRock--at--Excite--dot--com@mta5.snfc21.pbi.net>

>  4a) I have renamed jdb7.0-1.1.jar to postgresql.jar and then copied that
> .jar file into as many places as seems reasonable and not so
reasonable(yes
> I have copies all over the place at present), yet still get this error at
> run time.
>
> H:\JavaLessons\ch18\fig18_24>java TableDisplayPG1
> Failed to load JDBC/ODBC driver.
> java.lang.ClassNotFoundException: org.postgresql.Driver
>      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>         and about 10 more lines of errors...