RE: JDBC Problem
RE: JDBC Problem
От:
Peter Mount <petermount@maidstone.gov.uk>
Дата:
What version of the driver are you using?
Versions 6.5.x and earlier used postgresql.Driver but 7.0 onwards uses
org.postgresql.Driver
Peter
--
Peter Mount
Enterprise Support Officer, Maidstone Borough Council
Email: petermount@maidstone.gov.uk
WWW: http://www.maidstone.gov.uk
All views expressed within this email are not the views of Maidstone Borough
Council
-----Original Message-----
From: tony [mailto:tony@uickarate.com]
Sent: Thursday, November 16, 2000 2:55 PM
To: pgsql-interfaces
Subject: [INTERFACES] JDBC Problem
I have a problem with loading the JDBC Driver.
So far, my java code does nothing but to load the driver, and
it gives SQLException with message "No suitable driver".
I made the postgresql.jar with
>make jdbc2
(because I am using jdk1.3)
and I used
>jar tf postgresql.jar
to make sure that the driver was included.
(postgresql/Driver.class)
My CLASSPATH is following:
:/usr/local/lib/postgresql.jar:/usr/local/jdk1.3/bin/:/home/tony/classes/
I am trying to load the driver by doing
>Class.forName("postgresql.Driver");
This is under linux platform. Please let me know what could be
wrong if you see anything wrong.
Thanks!
JDBC prob. Continued
От:
"tony" <tony@uickarate.com>
Дата:
I'm using 7.0.
Greg told me that SQLException is thrown by
getConnection();
so I've changed by getConnection to
DriverManager.getConnection("jdbc:postgresql:database_name", "postgres",
"password");
and the error changed to something like this:
SQLException: Connection refused. Check that th ehostname and port is
correct, and
tha thte postmaster is runing with the -i flag, which enables TCP/IP
networking.
Any ideas??
Thanks,
Tony
----- Original Message -----
From: "Peter Mount"
To: "'tony'" ; "pgsql-interfaces"
Sent: Thursday, November 16, 2000 11:14 AM
Subject: RE: [INTERFACES] JDBC Problem
> What version of the driver are you using?
>
> Versions 6.5.x and earlier used postgresql.Driver but 7.0 onwards uses
> org.postgresql.Driver
>
> Peter
>
> --
> Peter Mount
> Enterprise Support Officer, Maidstone Borough Council
> Email: petermount@maidstone.gov.uk
> WWW: http://www.maidstone.gov.uk
> All views expressed within this email are not the views of Maidstone
Borough
> Council
>
>
> -----Original Message-----
> From: tony [mailto:tony@uickarate.com]
> Sent: Thursday, November 16, 2000 2:55 PM
> To: pgsql-interfaces
> Subject: [INTERFACES] JDBC Problem
>
>
> I have a problem with loading the JDBC Driver.
> So far, my java code does nothing but to load the driver, and
> it gives SQLException with message "No suitable driver".
> I made the postgresql.jar with
> >make jdbc2
> (because I am using jdk1.3)
>
> and I used
> >jar tf postgresql.jar
> to make sure that the driver was included.
> (postgresql/Driver.class)
>
> My CLASSPATH is following:
> :/usr/local/lib/postgresql.jar:/usr/local/jdk1.3/bin/:/home/tony/classes/
>
> I am trying to load the driver by doing
> >Class.forName("postgresql.Driver");
>
> This is under linux platform. Please let me know what could be
> wrong if you see anything wrong.
>
>
> Thanks!
>
Re: JDBC prob. Continued
От:
"tony" <tony@uickarate.com>
Дата:
BTW, I have PGOPT="i"
for postgresql.init already.
Tony
----- Original Message -----
From: "tony"
To: "pgsql-interfaces"
Sent: Thursday, November 16, 2000 11:23 AM
Subject: [INTERFACES] JDBC prob. Continued
> I'm using 7.0.
> Greg told me that SQLException is thrown by
> getConnection();
> so I've changed by getConnection to
> DriverManager.getConnection("jdbc:postgresql:database_name", "postgres",
> "password");
> and the error changed to something like this:
> SQLException: Connection refused. Check that th ehostname and port is
> correct, and
> tha thte postmaster is runing with the -i flag, which enables TCP/IP
> networking.
>
>
> Any ideas??
>
> Thanks,
>
> Tony
>
> ----- Original Message -----
> From: "Peter Mount"
> To: "'tony'" ; "pgsql-interfaces"
>
> Sent: Thursday, November 16, 2000 11:14 AM
> Subject: RE: [INTERFACES] JDBC Problem
>
>
> > What version of the driver are you using?
> >
> > Versions 6.5.x and earlier used postgresql.Driver but 7.0 onwards uses
> > org.postgresql.Driver
> >
> > Peter
> >
> > --
> > Peter Mount
> > Enterprise Support Officer, Maidstone Borough Council
> > Email: petermount@maidstone.gov.uk
> > WWW: http://www.maidstone.gov.uk
> > All views expressed within this email are not the views of Maidstone
> Borough
> > Council
> >
> >
> > -----Original Message-----
> > From: tony [mailto:tony@uickarate.com]
> > Sent: Thursday, November 16, 2000 2:55 PM
> > To: pgsql-interfaces
> > Subject: [INTERFACES] JDBC Problem
> >
> >
> > I have a problem with loading the JDBC Driver.
> > So far, my java code does nothing but to load the driver, and
> > it gives SQLException with message "No suitable driver".
> > I made the postgresql.jar with
> > >make jdbc2
> > (because I am using jdk1.3)
> >
> > and I used
> > >jar tf postgresql.jar
> > to make sure that the driver was included.
> > (postgresql/Driver.class)
> >
> > My CLASSPATH is following:
> >
:/usr/local/lib/postgresql.jar:/usr/local/jdk1.3/bin/:/home/tony/classes/
> >
> > I am trying to load the driver by doing
> > >Class.forName("postgresql.Driver");
> >
> > This is under linux platform. Please let me know what could be
> > wrong if you see anything wrong.
> >
> >
> > Thanks!
> >
>
>
Re: JDBC prob. Continued
От:
Michael Stephenson <mstephenson@tirin.openworld.co.uk>
Дата:
On Thu, 16 Nov 2000, tony wrote:
> I'm using 7.0.
> Greg told me that SQLException is thrown by
> getConnection();
> so I've changed by getConnection to
> DriverManager.getConnection("jdbc:postgresql:database_name", "postgres",
> "password");
> and the error changed to something like this:
> SQLException: Connection refused. Check that th ehostname and port is
> correct, and
> tha thte postmaster is runing with the -i flag, which enables TCP/IP
> networking.
>
> Any ideas??
From reading the error message I'd suggest, either you have the hostname
and port incorrect, correct use is:
DriverManager.getConnection("jdbc:postgresql://[host]:[port]/[db_name]","[username]", "[password]");
Or you're not running postmaster with the -i flag, I use:
postmaster -i -p [port] -D [data directory]
If it's neither of those, then I'm sorry for being patronising.
Hope this helps,
Michael Stephenson
Re: JDBC prob. Continued
От:
"tony" <tony@uickarate.com>
Дата:
The host could be just localhost
if this is running only on localhost, right?
Or do I have to specify an IP?
Thanks,
Tony
----- Original Message -----
From: "Michael Stephenson"
To: "tony"
Cc: "pgsql-interfaces"
Sent: Thursday, November 16, 2000 12:37 PM
Subject: Re: [INTERFACES] JDBC prob. Continued
> On Thu, 16 Nov 2000, tony wrote:
>
> > I'm using 7.0.
> > Greg told me that SQLException is thrown by
> > getConnection();
> > so I've changed by getConnection to
> > DriverManager.getConnection("jdbc:postgresql:database_name", "postgres",
> > "password");
> > and the error changed to something like this:
> > SQLException: Connection refused. Check that th ehostname and port is
> > correct, and
> > tha thte postmaster is runing with the -i flag, which enables TCP/IP
> > networking.
> >
> > Any ideas??
>
> >From reading the error message I'd suggest, either you have the hostname
> and port incorrect, correct use is:
>
> DriverManager.getConnection(
> "jdbc:postgresql://[host]:[port]/[db_name]",
> "[username]", "[password]");
>
> Or you're not running postmaster with the -i flag, I use:
>
> postmaster -i -p [port] -D [data directory]
>
> If it's neither of those, then I'm sorry for being patronising.
>
> Hope this helps,
>
> Michael Stephenson
>
>
Re: JDBC prob. Continued
От:
Christopher Farley <chris@northernbrewer.com>
Дата:
> so I've changed by getConnection to
> DriverManager.getConnection("jdbc:postgresql:database_name", "postgres",
> "password");
The above URL is not correct, it should be
jdbc:postgresql://localhost:5432/database_name
Note the two slashes after jdbc:postgresql:
I am not sure if localhost:5432 is required, but it won't hurt.
----
Christopher Farley
Northern Brewer / 1150 Grand Avenue / St. Paul, MN 55105
www.northernbrewer.com
RE: JDBC Problem
От:
Peter Mount <petermount@maidstone.gov.uk>
Дата:
What have you got your classpath set to?
--
Peter Mount
Enterprise Support Officer, Maidstone Borough Council
Email: petermount@maidstone.gov.uk
WWW: http://www.maidstone.gov.uk
All views expressed within this email are not the views of Maidstone Borough
Council
-----Original Message-----
From: tony [mailto:tony@uickarate.com]
Sent: Thursday, November 16, 2000 3:24 PM
To: pgsql-interfaces
Subject: Re: [INTERFACES] JDBC Problem
Michael, Peter, Chris,
Thanks for the advice. I forgot to mention that
I tried org.postgresql.Driver and it didn't work...
Tony
----- Original Message -----
From: "Michael Stephenson"
To: "tony"
Cc: "pgsql-interfaces"
Sent: Thursday, November 16, 2000 11:12 AM
Subject: Re: [INTERFACES] JDBC Problem
> > I am trying to load the driver by doing
> > >Class.forName("postgresql.Driver");
>
> Try:
>
> Class.forName("org.postgresql.Driver");
>
> Hope this helps
>
> Michael Stephenson
>
>
Tomcat & JDBC
От:
Tony Nakamura <tony@uickarate.com>
Дата:
Thanks everyone for the help on JDBC. I finally got JDBC to work. ....of course, I am facing an another one. So please help me if you could. Thanks in advance. My DB connection works perfectly when I am writing an application, but it gives the ClassNotFoundException error when I write a servlet. I am pretty sure it's the setting for tomcat that I am using. I have set following in the tomcat.properties file: wrapper.bin.parameters=-Djdbc.drivers=org.postgresql.Driver wrapper.classpath=/usr/local/lib/postgresql.jar I am also setting the CLASSPATH environmental variable, so I've tried wrapper.bin.parameter=NONE and didn't work. Tony
Re: Tomcat & JDBC
От:
Greg Speegle <Greg@10happythings.com>
Дата:
I was able to get tomcat to work with postgres by putting the jar file in /usr/local/tomcat/lib, which is the default place for tomcat to look for libraries in my installation. Also, are you using the right jar file? I know you can name it whatever you want, but the download name I have is jdbc7_0-1_2.jar, while the old jar file was called postgresql.jar. Good luck, Greg Speegle Tony Nakamura wrote: > Thanks everyone for the help on JDBC. I finally got JDBC to work. > ....of course, I am facing an another one. So please help me if you could. > Thanks in advance. > > My DB connection works perfectly when I am writing an application, but > it gives the ClassNotFoundException error when I write a servlet. I am > pretty > sure it's the setting for tomcat that I am using. I have set following in > the tomcat.properties > file: > > wrapper.bin.parameters=-Djdbc.drivers=org.postgresql.Driver > wrapper.classpath=/usr/local/lib/postgresql.jar > > I am also setting the CLASSPATH environmental variable, so > I've tried wrapper.bin.parameter=NONE and didn't work. > > Tony
Re: Tomcat & JDBC
От:
Tony Nakamura <tony@uickarate.com>
Дата:
Wow!! You must be able to see my computer... It was exactly what's needed. I guess it was the typical newbie question?? In anycase, thanks a lot, Greg!! Tony Greg Speegle wrote: > I was able to get tomcat to work with postgres by putting the jar file > in /usr/local/tomcat/lib, which is the default place for tomcat to look > for libraries in my installation. > > Also, are you using the right jar file? I know you can name it whatever > you want, but the download name I have is jdbc7_0-1_2.jar, while the > old jar file was called postgresql.jar. > > Good luck, > Greg Speegle > > Tony Nakamura wrote: > > > Thanks everyone for the help on JDBC. I finally got JDBC to work. > > ....of course, I am facing an another one. So please help me if you could. > > Thanks in advance. > > > > My DB connection works perfectly when I am writing an application, but > > it gives the ClassNotFoundException error when I write a servlet. I am > > pretty > > sure it's the setting for tomcat that I am using. I have set following in > > the tomcat.properties > > file: > > > > wrapper.bin.parameters=-Djdbc.drivers=org.postgresql.Driver > > wrapper.classpath=/usr/local/lib/postgresql.jar > > > > I am also setting the CLASSPATH environmental variable, so > > I've tried wrapper.bin.parameter=NONE and didn't work. > > > > Tony
currval() problem
От:
"tony" <tony@uickarate.com>
Дата:
Hello I have a problem with currval() through JDBC. My nextval() updates the counter of sequences, but currval() returns no value even after I call nextval(). Both work fine when I try them through psql. Have you encountered this problem before?? Tony
Re: currval() problem
От:
Marko Kreen <marko@l-t.ee>
Дата:
On Tue, Nov 28, 2000 at 08:16:08PM -0500, tony wrote: > Hello > > I have a problem with currval() through JDBC. > My nextval() updates the counter of sequences, but > currval() returns no value even after I call nextval(). > Both work fine when I try them through psql. > Have you encountered this problem before?? does this help? con.setAutoCommit(false); -- marko