Re: forName finds Driver but getConnection doesn't

From: Dennis King <d_r_king(at)yahoo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: forName finds Driver but getConnection doesn't
Date: 2002-11-20 16:20:15
Message-ID: 20021120162015.29454.qmail@web40408.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

--- Haris Peco <snpe(at)snpe(dot)co(dot)yu> wrote:
> On Tuesday 19 November 2002 11:46 pm, Dennis King wrote:
> > Hi All. I can't get to my carefully set-up database through java
> with
> > a simple test program. I think I've hit most of the required
> set-up
> > points:
> >
> > * I've got all the postgresql packages installed (checked with
> rpm
> > -qa | grep -i postgres; they're there, including the jdbc one).
> > * I set tcpip_socket = true in
> /var/lib/pgsql/data/postgresql.conf.
> > * I also updated /etc/rc.d/init.d/ so that postmaster gets -o
> "-i";
> > this means that the "pg_ctl -D /var/lib/pgsql/data status"
> command
> > shows the -i flag was passed in.
> > * I have the right driver in the classpath (I pass in -classpath
> > /usr/share/pgsql/pgjdbc2.jar when compiling and running; for some
> > reason, copying the jar to /jre/lib/ext doesn't work with any
> jars
> > for me).
> > * I added the lines "host all 127.0.0.1 255.255.255.255 trust"
> and
> > "host all 192.168.0.0 255.255.0.0 trust" to
> > /var/lib/pgsql/data/pg_hba.conf
> > * I created a new database, "webdb"
> > * I added the user "xxx" with the password "yyy" to the database,
> and
> > verified by logging into psql with -U xxx (had pg_hba.conf set to
> > password so was challenged and succeeded)
> >
> > With all of this, my java program has these lines:
> >
> > Connection dbConnection = null;
> > try{
> > Class.forName("org.postgresql.Driver");
> > dbConnection =
> DriverManager.getConnection("jdbc:postgresql:webdb",
> > "xxx", "yyy");
> > }
> >
> > I get the error "java.sql.SQLException: Driver not found for URL:
> > jdbc:postgresql:webdb". (Note it's finding the driver with the
> > forName() method call).
> >
> > I've tried using jdbc:postgresql://localhost/webdb.
> >
> > I have, of course, restarted the box several times.
> >
> > Any pointers you have would be extremely gratefully received.
> >
> Hello Dennis,
> jdbc:postgresql:webdb is not good URL
> If you database webdb and server localhost then second URL is good
> and problem is in TCP connection - what is your port ?
>
> regards
> Haris Peco

Haris et al.,

I never specified a port in the install, so Postgresql should be
running on the default port, 5432. I did uncomment the line in the
.conf file (all lines seem to be commmented out by default). (By the
way, my .conf file has all lines commented out, which I presume means
that it's just operating on the defaults. Is there any chance my
firewall (default product shipped with Red Hat 8) would be
interfering with the communication?

Just in case it helps, the SQLException stack trace is this:

java.sql.SQLException: Driver not found for URL:
jdbc:postgresql://localhost:webdb
at 0x4028115f: java.lang.Throwable.Throwable(java.lang.String)
(/usr/lib/libgcj.so.3)
at 0x402740d2: java.lang.Exception.Exception(java.lang.String)
(/usr/lib/libgcj.so.3)
at 0x40316294:
java.sql.SQLException.SQLException(java.lang.String,
java.lang.String, int) (/usr/lib/libgcj.so.3)
at 0x40316244:
java.sql.SQLException.SQLException(java.lang.String)
(/usr/lib/libgcj.so.3)
at 0x40316102:
java.sql.DriverManager.getConnection(java.lang.String,
java.util.Properties) (/usr/lib/libgcj.so.3)
at 0x4031603a:
java.sql.DriverManager.getConnection(java.lang.String,
java.lang.String, java.lang.String) (/usr/lib/libgcj.so.3)
at 0x4039d347: ffi_call_SYSV (/usr/lib/libgcj.so.3)
at 0x4039d307: ffi_raw_call (/usr/lib/libgcj.so.3)
at 0x40248528:
_Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation)
(/usr/lib/libgcj.so.3)
at 0x40248e34: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw,
_Jv_InterpMethodInvocation) (/usr/lib/libgcj.so.3)
at 0x40246424: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw,
void) (/usr/lib/libgcj.so.3)
at 0x4039d1bc: ?? (??:0)
at 0x4025b308: gnu.gcj.runtime.FirstThread.call_main()
(/usr/lib/libgcj.so.3) at 0x402c60b1:
gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.3)
at 0x40267fdc: _Jv_ThreadRun(java.lang.Thread)
(/usr/lib/libgcj.so.3)
at 0x4023478c: _Jv_RunMain(java.lang.Class, byte const, int, byte
const, boolean) (/usr/lib/libgcj.so.3)
at 0x08048900: __gcj_personality_v0
(jdbc.driver=org.postgresql.Driver)
at 0x420158d4: __libc_start_main
(jdbc.driver=org.postgresql.Driver)
at 0x080486c1: _Jv_RegisterClasses
(jdbc.driver=org.postgresql.Driver)
java.sql.SQLException: Driver not found for URL:
jdbc:postgresql://localhost:webdb

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Haris Peco 2002-11-20 16:53:09 Re: forName finds Driver but getConnection doesn't
Previous Message Apu Ziad Mannan 2002-11-20 16:11:28 AbstractMethodError exception on an executeUpdate call