From: | "Steven Murphy" <stevenmurphy(at)hotmail(dot)com> |
---|---|
To: | Dave(at)micro-automation(dot)net, barry(at)xythos(dot)com |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Connection Problem with JDBC |
Date: | 2002-02-25 14:05:35 |
Message-ID: | LAW2-F18g3OBvB8J0QL00014703@hotmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Dave,
Where abouts would I put this code? I tried just adding it to the bottom of
the program but when I compiled I got some error messages.
Cheers
Steve.
From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
Reply-To: <Dave(at)micro-automation(dot)net>
To: "'Steven Murphy'" <stevenmurphy(at)hotmail(dot)com>, <barry(at)xythos(dot)com>
CC: <pgsql-jdbc(at)postgresql(dot)org>
Subject: RE: [JDBC] Connection Problem with JDBC
Date: Tue, 12 Feb 2002 09:32:54 -0500
Steve,
What do you get when you add the following code
Enumeration e = DriverManager.getDrivers();
While(e.hasNext()){
System.out.println(e.nextElement());
}
Dave
-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Steven Murphy
Sent: Monday, February 11, 2002 3:13 PM
To: Dave(at)micro-automation(dot)net; barry(at)xythos(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] Connection Problem with JDBC
No I'm using Red Hat Linux 7.1
Steve.
From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
Reply-To: <Dave(at)micro-automation(dot)net>
To: "'Barry Lind'" <barry(at)xythos(dot)com>, "'Steven Murphy'"
<stevenmurphy(at)hotmail(dot)com>
CC: <pgsql-jdbc(at)postgresql(dot)org>
Subject: RE: [JDBC] Connection Problem with JDBC
Date: Mon, 11 Feb 2002 13:27:18 -0500
I just verified that it works under linux as advertised, but still
doesn't work under windoze. Steven, I presume you are trying to use this
on a windows machine?
Dave
-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Barry Lind
Sent: Monday, February 11, 2002 12:46 PM
To: Steven Murphy
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] Connection Problem with JDBC
Steven,
This works for me.
[blind(at)barry work]$ echo $CLASSPATH
.:/home/blind/work/wfs/jars/postgresjdbc.jar
[blind(at)barry work]$ java -Djdbc.drivers=org.postgresql.Driver
ConnectDemo jdbc:postgresql://localhost:5432/files blind "" Connection
successful. Connection as String: org(dot)postgresql(dot)jdbc2(dot)Connection(at)4ac268
I am running on RedHat 7.2, jdk 1.3.1_01 with the postgres 7.2 jdbc
drivers.
Are you sure that the jdbc jar file is in your CLASSPATH, and that you
have exported the CLASSPATH setting back to the environment?
thanks,
--Barry
Steven Murphy wrote:
> Hi,
>
> I'm trying to connect to a PostgreSQL database using JDBC but when I
> run > the program I get an error message saying "No suitable driver".
> > I'm using PostgreSQL 7.1.3 and java 1.3.1_01. > > I have added
the jdbc7.1-1.2.jar file to the CLASSPATH. > > The command I am using
to run the program is > java -Djdbc.drivers=org.postgresql.Driver
ConnectDemo > jdbc:postgresql:javatest postgres ' ' > > The program
I'm trying to use is :- > > import java.sql.*; > > public class
ConnectDemo { > > public static void main(String[] argv) {
> // No need to register the driver, since the user
> // used -Djdbc.drivers to set it.
>
> // Check the arguments.
> //
> if (argv.length < 3) {
> usage();
> }
> String url = argv[0];
> String user = argv[1];
> String pass = argv[2];
>
> // Invoke getConnection() to create the
> // connection object.
> //
> Connection conn;
> try {
> conn = DriverManager.getConnection(url, user, pass);
> System.out.println("Connection successful.");
> System.out.println("Connection as String: " + conn);
> } catch (SQLException e) {
> System.err.println( e.getMessage() );
> System.exit(-1);
> }
> }
>
> static void usage() {
> System.err.println("Usage:");
> System.err.print("java -Djdbc.drivers=DRIVERCLASS PROGRAM ");
> System.err.println("URL USER PASS");
> System.exit(-1);
>
> }
> }
>
> I would be greatful for any help as I trying to do this for my final
> year project at University and the deadline is fast approaching. > >
Cheers > Steven Murphy. > >
_________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> > > ---------------------------(end of >
broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to
majordomo(at)postgresql(dot)org)
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2002-02-25 14:12:44 | Re: set parameter not enabled? |
Previous Message | Nick Fankhauser | 2002-02-25 14:04:22 | Re: Connection Problem with JDBC |