pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki@enterprisedb.com>
To: Jonathan Mast <jonathan.h.mast@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Queries with 'AND' clauses not returning results
Date: Mon, 26 Nov 2007 20:39:22 +0000
Message-ID: <474B2EFA.6010506@enterprisedb.com> (raw)
In-Reply-To: <85e352e10711261224h71092c7cvfe17df9653874dff@mail.gmail.com>
References: <85e352e10711261224h71092c7cvfe17df9653874dff@mail.gmail.com>

Jonathan Mast wrote:
> I have some jsp with calls to our pg database, and yes, I know this is
> not the optimal way to do it, but we can't stop everything to
> re-engineer our website to use Struts or whatever.

Don't worry, we're not here to judge your development methodologies :).

> specs:
> Apache 1.3.33
> Tomcat 5.5.17
> postgresql 8.1.3

Running an old version of PostgreSQL, however, is frowned upon ;-). 
Seriously, you should upgrade.

 > That said, the problem is that statements such as:
 > "SELECT * FROM tbl_someTable WHERE email='nobody@nowhere.com' ;
 > work fine
 >
 > while statements like this don't work (no records returned):
 > "SELECT * FROM tbl_someTable WHERE email='nobody@nowhere.com' AND
 > password='abcd'";
 > And quoting the field 'password' doesn't make a difference.
 >
 > I know such records actually exist because I'm printing out the query
 > on the webpage, copying it to pgAdmin and executing with results.

That obviously should work, so there's something else than just that 
query involved here. Perhaps a quoting problem or something, but it's 
hard to say without seeing the actual code.

BTW, if the values for email and password are coming from user input, 
you must be careful to quote them properly, or use a prepared statement.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



view thread (2+ messages)

Message-ID: <474B2EFA.6010506@enterprisedb.com>
Permalink:  ../474B2EFA.6010506@enterprisedb.com/
Also on:    postgresql.org/message-id/474B2EFA.6010506@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: heikki@enterprisedb.com, jonathan.h.mast@gmail.com
  Subject: Re: Queries with 'AND' clauses not returning results
  In-Reply-To: <474B2EFA.6010506@enterprisedb.com>
  References: <85e352e10711261224h71092c7cvfe17df9653874dff@mail.gmail.com> <474B2EFA.6010506@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox