Thread: [Q] Can't get simple JDBC connection to work: "no suitable driver"

[Q] Can't get simple JDBC connection to work: "no suitable driver"

From
Amandeep Jawa
Date:
(PLEASE email any replies to me directy as well as posting)

Hey folks -

I hope someone can help.  I'm trying to get a VERY simple JDBC connection
working with the JDBC drivers but I am consistently getting a "no suitable
driver" error.

I am trying a very very simple test program to access my little PostgreSQL
database & I am using the jdbc driver: jdbc7.1-1.2.jar (binary downloaded
from www.postgresql.org).

The error I'm getting is:

Exception in thread "main" java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getConnection(DriverManager.java:537)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at testpost.main(testpost.java:14)


The command I'm running is:

java -cp /usr/share/pgsql/jdbc7.1-1.2.jar testpost

The code is:

// testpost.java

import java.sql.*;

public class testpost
{

    public static void main(String argv[]) throws Exception
    {
                System.out.println("Beginning Postgres Test");
                Class.forName("org.postgresql.Driver");

                System.out.println("Loaded Driver.");
                  Connection conn = DriverManager.getConnection(
                        "jdbc:postgres:test",
                        "postgres",
                        "notreallymypassword"
                );

                System.out.println("Got connection.");
/* COMMENTED OUT UNTIL I KNOW THE REST WORKS
                Statement stmt = conn.createStatement();
                ResultSet rset = stmt.executeQuery("SELECT now();");

                System.out.println("Ran now query..\nResults:\n");
                while (rset.next())
                {
                        System.out.println(rset.getString(1));
                }

                rset.close();
                stmt.close();
  */
                conn.close();

                System.out.println("Closed connection & Ended Test");

        }

}



The ouput I get is:

Beginning Postgres Test
Loaded Driver.
Exception in thread "main" java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getConnection(DriverManager.java:537)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at testpost.main(testpost.java:14)

I'm using postgres 7.1.3 installed from RPMs (from Postgres) on Red Hat
Linux 7.1 with Sun's jdk 1.3.1 also installed from RPMs (from Sun).

I have a "postgres" user on my machine.  I have made the database "test".
Not that I think these things matter because it doesn't seem to be getting
that far.  I am starting the postgres server from the root user with the
following command:
/etc/rc.d/init.d/postgresql start
& it seems to be starting fine.  I have also turned on tcp-ip connections in
the conf file.

Couple of other facts:
 - One thing I notice is that the documentation all refers to a
"postgressql.jar" which I can't find.  I can find the "jdbc7.1-1.2.jar"
which is what I'm using.

- One other thing I have tried is to rebuild the drivers from scratch - this
does give me a postgresql.jar - but the error is the same.

- I have also noticed that the jar files are not always the same size:
jdbc7.1-1.2.jar from postgresql-jdbc-7.1.3-1PGDG.i386.rpm : 88169 bytes
jdbc7.1-1.2.jar from jdbc.postgresql.org : 93011 bytes
But the error is the same :-)


Any help would be greatly appreciated - and please email replies to me
directly as well as the list.

THANKS in advance.
'deep


----------------------------------
Amandeep Jawa
Worker Bee Software
----------------------------------
deep@worker-bee.com
225A Dolores St.
San Francisco, CA 94103-2202

Home: 415 255 6257 (ALL MALP)

professional: http://www.worker-bee.com
personal: http://www.deeptrouble.com
political: http://www.sflcv.org





Re: [Q] Can't get simple JDBC connection to work: "no suitable driver"

From
Liam Stewart
Date:
Try changing the connection url to the following:

"jdbc:postgresql:test"

This should do the trick. postgres is not a valid subprotocol which explains
the error message that you're getting. postgresql is the only subprotocol
recognized by the PostgreSQL JDBC driver.

Liam

On Thu, Oct 11, 2001 at 04:28:06PM -0700, Amandeep Jawa wrote:
> (PLEASE email any replies to me directy as well as posting)
>
> Hey folks -
>
> I hope someone can help.  I'm trying to get a VERY simple JDBC connection
> working with the JDBC drivers but I am consistently getting a "no suitable
> driver" error.
>
> I am trying a very very simple test program to access my little PostgreSQL
> database & I am using the jdbc driver: jdbc7.1-1.2.jar (binary downloaded
> from www.postgresql.org).
>
> The error I'm getting is:
>
> Exception in thread "main" java.sql.SQLException: No suitable driver
>     at java.sql.DriverManager.getConnection(DriverManager.java:537)
>     at java.sql.DriverManager.getConnection(DriverManager.java:177)
>     at testpost.main(testpost.java:14)
>
>
> The command I'm running is:
>
> java -cp /usr/share/pgsql/jdbc7.1-1.2.jar testpost
>
> The code is:
>
> // testpost.java
>
> import java.sql.*;
>
> public class testpost
> {
>
>     public static void main(String argv[]) throws Exception
>     {
>                 System.out.println("Beginning Postgres Test");
>                 Class.forName("org.postgresql.Driver");
>
>                 System.out.println("Loaded Driver.");
>                   Connection conn = DriverManager.getConnection(
>                         "jdbc:postgres:test",
>                         "postgres",
>                         "notreallymypassword"
>                 );
>
>                 System.out.println("Got connection.");
> /* COMMENTED OUT UNTIL I KNOW THE REST WORKS
>                 Statement stmt = conn.createStatement();
>                 ResultSet rset = stmt.executeQuery("SELECT now();");
>
>                 System.out.println("Ran now query..\nResults:\n");
>                 while (rset.next())
>                 {
>                         System.out.println(rset.getString(1));
>                 }
>
>                 rset.close();
>                 stmt.close();
>   */
>                 conn.close();
>
>                 System.out.println("Closed connection & Ended Test");
>
>         }
>
> }
>
>
>
> The ouput I get is:
>
> Beginning Postgres Test
> Loaded Driver.
> Exception in thread "main" java.sql.SQLException: No suitable driver
>     at java.sql.DriverManager.getConnection(DriverManager.java:537)
>     at java.sql.DriverManager.getConnection(DriverManager.java:177)
>     at testpost.main(testpost.java:14)
>
> I'm using postgres 7.1.3 installed from RPMs (from Postgres) on Red Hat
> Linux 7.1 with Sun's jdk 1.3.1 also installed from RPMs (from Sun).
>
> I have a "postgres" user on my machine.  I have made the database "test".
> Not that I think these things matter because it doesn't seem to be getting
> that far.  I am starting the postgres server from the root user with the
> following command:
> /etc/rc.d/init.d/postgresql start
> & it seems to be starting fine.  I have also turned on tcp-ip connections in
> the conf file.
>
> Couple of other facts:
>  - One thing I notice is that the documentation all refers to a
> "postgressql.jar" which I can't find.  I can find the "jdbc7.1-1.2.jar"
> which is what I'm using.
>
> - One other thing I have tried is to rebuild the drivers from scratch - this
> does give me a postgresql.jar - but the error is the same.
>
> - I have also noticed that the jar files are not always the same size:
> jdbc7.1-1.2.jar from postgresql-jdbc-7.1.3-1PGDG.i386.rpm : 88169 bytes
> jdbc7.1-1.2.jar from jdbc.postgresql.org : 93011 bytes
> But the error is the same :-)
>
>
> Any help would be greatly appreciated - and please email replies to me
> directly as well as the list.
>
> THANKS in advance.
> 'deep
>
>
> ----------------------------------
> Amandeep Jawa
> Worker Bee Software
> ----------------------------------
> deep@worker-bee.com
> 225A Dolores St.
> San Francisco, CA 94103-2202
>
> Home: 415 255 6257 (ALL MALP)
>
> professional: http://www.worker-bee.com
> personal: http://www.deeptrouble.com
> political: http://www.sflcv.org
>
>
>
>
>
> ---------------------------(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

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

Re: [Q] Can't get simple JDBC connection to work: "no suitable driver"

From
"Dave Cramer"
Date:
Change

"jdbc:postgres:test",

To

"jdbc:postgresql:test"

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Amandeep Jawa
Sent: October 11, 2001 7:28 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] [Q] Can't get simple JDBC connection to work: "no
suitable driver"


(PLEASE email any replies to me directy as well as posting)

Hey folks -

I hope someone can help.  I'm trying to get a VERY simple JDBC
connection working with the JDBC drivers but I am consistently getting a
"no suitable driver" error.

I am trying a very very simple test program to access my little
PostgreSQL database & I am using the jdbc driver: jdbc7.1-1.2.jar
(binary downloaded from www.postgresql.org).

The error I'm getting is:

Exception in thread "main" java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getConnection(DriverManager.java:537)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at testpost.main(testpost.java:14)


The command I'm running is:

java -cp /usr/share/pgsql/jdbc7.1-1.2.jar testpost

The code is:

// testpost.java

import java.sql.*;

public class testpost
{

    public static void main(String argv[]) throws Exception
    {
                System.out.println("Beginning Postgres Test");
                Class.forName("org.postgresql.Driver");

                System.out.println("Loaded Driver.");
                  Connection conn = DriverManager.getConnection(
                        "jdbc:postgres:test",
                        "postgres",
                        "notreallymypassword"
                );

                System.out.println("Got connection.");
/* COMMENTED OUT UNTIL I KNOW THE REST WORKS
                Statement stmt = conn.createStatement();
                ResultSet rset = stmt.executeQuery("SELECT now();");

                System.out.println("Ran now query..\nResults:\n");
                while (rset.next())
                {
                        System.out.println(rset.getString(1));
                }

                rset.close();
                stmt.close();
  */
                conn.close();

                System.out.println("Closed connection & Ended Test");

        }

}



The ouput I get is:

Beginning Postgres Test
Loaded Driver.
Exception in thread "main" java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getConnection(DriverManager.java:537)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at testpost.main(testpost.java:14)

I'm using postgres 7.1.3 installed from RPMs (from Postgres) on Red Hat
Linux 7.1 with Sun's jdk 1.3.1 also installed from RPMs (from Sun).

I have a "postgres" user on my machine.  I have made the database
"test". Not that I think these things matter because it doesn't seem to
be getting that far.  I am starting the postgres server from the root
user with the following command: /etc/rc.d/init.d/postgresql start & it
seems to be starting fine.  I have also turned on tcp-ip connections in
the conf file.

Couple of other facts:
 - One thing I notice is that the documentation all refers to a
"postgressql.jar" which I can't find.  I can find the "jdbc7.1-1.2.jar"
which is what I'm using.

- One other thing I have tried is to rebuild the drivers from scratch -
this does give me a postgresql.jar - but the error is the same.

- I have also noticed that the jar files are not always the same size:
jdbc7.1-1.2.jar from postgresql-jdbc-7.1.3-1PGDG.i386.rpm : 88169 bytes
jdbc7.1-1.2.jar from jdbc.postgresql.org : 93011 bytes But the error is
the same :-)


Any help would be greatly appreciated - and please email replies to me
directly as well as the list.

THANKS in advance.
'deep


----------------------------------
Amandeep Jawa
Worker Bee Software
----------------------------------
deep@worker-bee.com
225A Dolores St.
San Francisco, CA 94103-2202

Home: 415 255 6257 (ALL MALP)

professional: http://www.worker-bee.com
personal: http://www.deeptrouble.com
political: http://www.sflcv.org





---------------------------(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: [Q] Can't get simple JDBC connection to work: "no suitable driver"

From
"Nick Fankhauser"
Date:
>                   Connection conn = DriverManager.getConnection(
>                         "jdbc:postgres:test",
>                         "postgres",
>                         "notreallymypassword"
>

I think it's just that the url should be jdbc:postrgesql:text (add the "ql")

-Nick
--------------------------------------------------------------------------
Nick Fankhauser  nickf@ontko.com  Phone 1.765.935.4283  Fax 1.765.962.9788
Ray Ontko & Co.     Software Consulting Services     http://www.ontko.com/


Re: [Q] Can't get simple JDBC connection to work: "no suitable driver"

From
Brent Verner
Date:
On 11 Oct 2001 at 16:28 (-0700), Amandeep Jawa wrote:
| (PLEASE email any replies to me directy as well as posting)

try the conn url below.

|                 System.out.println("Loaded Driver.");
|                   Connection conn = DriverManager.getConnection(
|                         "jdbc:postgres:test",

              "jdbc:postgresql://localhost/test"

|                         "postgres",
|                         "notreallymypassword"
|                 );

hth.
  brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman