Обсуждение: No suitable driver found exception

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

No suitable driver found exception

От
"Amanda K. Martino"
Дата:
Hello,

I have a simple java class (myTest.java) that I'm trying to run. This
class uploads an RDFS schema into a postgresql database using three
methods: setAuthentication, which specifies the username and password
used to gain access to the database, setDBFunctionsPath, which specifies
the library containing the functions to actually store the RDF, and
store, which takes as parameters the URL of the RDF schema to be loaded
into the database, and the URL of the database into which the schema
will be loaded. When I try to run the class, I'm getting the following
exception:
SQLException: No suitable driver
java.sql.SQLException: No suitable driver.

I have the postgresql.jar file in my classpath, as well the
jdbc7.1-1.2.jar which I downloaded from the postgresql.org's jdbc site.
I'm using Postgresql v7.1.3 and JDBC v2.0. I'd appreciate any
suggestions to resolve this issue that anyone has.

Thank you very much,
Amanda Martino
amartino@mitre.org


Re: No suitable driver found exception

От
"Dave Cramer"
Дата:
Amanda,

Can you send the code?

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Amanda K. Martino
Sent: Thursday, January 31, 2002 2:41 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] No suitable driver found exception


Hello,

I have a simple java class (myTest.java) that I'm trying to run. This
class uploads an RDFS schema into a postgresql database using three
methods: setAuthentication, which specifies the username and password
used to gain access to the database, setDBFunctionsPath, which specifies
the library containing the functions to actually store the RDF, and
store, which takes as parameters the URL of the RDF schema to be loaded
into the database, and the URL of the database into which the schema
will be loaded. When I try to run the class, I'm getting the following
exception:
SQLException: No suitable driver
java.sql.SQLException: No suitable driver.

I have the postgresql.jar file in my classpath, as well the
jdbc7.1-1.2.jar which I downloaded from the postgresql.org's jdbc site.
I'm using Postgresql v7.1.3 and JDBC v2.0. I'd appreciate any
suggestions to resolve this issue that anyone has.

Thank you very much,
Amanda Martino
amartino@mitre.org


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Re: No suitable driver found exception

От
"Nick Fankhauser"
Дата:
This error usually means that the connection URL is not right. Try putting a
debug line into your code that prints the database URL just before it gets
used in the Store method. It should match one of these three forms:

jdbc:postgresql:database
jdbc:postgresql://host/database
jdbc:postgresql://host:port/database

-Nick

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Amanda K. Martino
> Sent: Thursday, January 31, 2002 2:41 PM
> To: pgsql-jdbc@postgresql.org
> Subject: [JDBC] No suitable driver found exception
>
>
> Hello,
>
> I have a simple java class (myTest.java) that I'm trying to run. This
> class uploads an RDFS schema into a postgresql database using three
> methods: setAuthentication, which specifies the username and password
> used to gain access to the database, setDBFunctionsPath, which specifies
> the library containing the functions to actually store the RDF, and
> store, which takes as parameters the URL of the RDF schema to be loaded
> into the database, and the URL of the database into which the schema
> will be loaded. When I try to run the class, I'm getting the following
> exception:
> SQLException: No suitable driver
> java.sql.SQLException: No suitable driver.
>
> I have the postgresql.jar file in my classpath, as well the
> jdbc7.1-1.2.jar which I downloaded from the postgresql.org's jdbc site.
> I'm using Postgresql v7.1.3 and JDBC v2.0. I'd appreciate any
> suggestions to resolve this issue that anyone has.
>
> Thank you very much,
> Amanda Martino
> amartino@mitre.org
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>


Quirks in driver and docs (Was: Re: No suitable driver found exception)

От
Stefano Reksten
Дата:
At 16.04 31/01/02 -0500, you wrote:
>This error usually means that the connection URL is not right. Try putting a
>debug line into your code that prints the database URL just before it gets
>used in the Store method. It should match one of these three forms:
>
>jdbc:postgresql:database
>jdbc:postgresql://host/database
>jdbc:postgresql://host:port/database

Hello list,
in order to understand a little bit more deeply JDBC, yesterday I went
digging the code while reading the JDBC 1.2 specifications.
Here are some quirks I found in the code, I think this could also help
Amanda solve her problem. I can volunteer to help fix these, if anyone has
the patience to explain me how to use CVS to check out the latest version
and how to send patches (I think I should send you the output of 'diff
oldversion newversion' but I am not sure). Anyway:

In Driver.java (prepared by ant for jdbc2), line 127, and 174, the URL is
specified as jdbc:org.postgresql://host:port..., but instead the working
version seems to be jdbc:postgresql://host..., so org.postgresql in the
docs should be changed to postgresql. This could be the reason why Amanda
gets no suitable driver exception. IIRC even a colleague of mine got into
this, but we solved changing the URL.

Line 392: getLogStream has been deprecated, because under jak 1.2 gave
deprecation warnings; this is correct as under jdk 1.2 the preferred method
would be getLogWriter.

Again in Driver.java, getPropertyInfo does not report that the user name is
mandatory. This is useful for GUIs.

In the abstract class Connection.java, the comment say that user and
password are mandatory, but this is incorrect since if the password is
missing an empty one is used. The comments don't go to the JavaDocs, but
for code-diggers like me it is preferrable to have correct comments.

Hope this helps, and pls let me know if I can volunteer to help a little
more. I'll be digging through the whole code in the next days... better say
nights ;)

Ciao,
         Stefano


Re: Quirks in driver and docs (Was: Re: No suitable driver found exception)

От
Barry Lind
Дата:
Stefano,

Patches are always welcome (although until 7.2 gets out the door, they
are being held up, until the code line opens again for 7.3 changes).
For access to cvs there are instructions on the developer.postgresql.org
site.

Now to your questions:

> In Driver.java (prepared by ant for jdbc2), line 127, and 174, the URL
> is specified as jdbc:org.postgresql://host:port..., but instead the
> working version seems to be jdbc:postgresql://host..., so org.postgresql
> in the docs should be changed to postgresql. This could be the reason
> why Amanda gets no suitable driver exception. IIRC even a colleague of
> mine got into this, but we solved changing the URL.


This should be 'jdbc:postgresql://host...' the comments are wrong.

>
> Line 392: getLogStream has been deprecated, because under jak 1.2 gave
> deprecation warnings; this is correct as under jdk 1.2 the preferred
> method would be getLogWriter.


The problem here is that we build the same code under both jdk1.1 and
jdk1.2+ environments.  So any changes to this need to work in both
environments (or build tricks need to be applied to get things working
for both).

>
> Again in Driver.java, getPropertyInfo does not report that the user name
> is mandatory. This is useful for GUIs.


I agree that username should be reported as mandatory.

 >

> In the abstract class Connection.java, the comment say that user and
> password are mandatory, but this is incorrect since if the password is
> missing an empty one is used. The comments don't go to the JavaDocs, but
> for code-diggers like me it is preferrable to have correct comments.


Password is not required.  The comments are incorrect.


thanks,
--Barry