column not found !

From: Savio Domnic <saviodomnic(at)yahoo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: column not found !
Date: 2003-07-17 16:20:04
Message-ID: 20030717162004.98288.qmail@web40513.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,
I am trying to retrive a record from pqsl DB using the
following steps.

First I prepare a String Buffer "prepareSql".

prepareSql.append("Select");

if(req.getParameter("firstname") != null){
prepareSql.append(" name,");
}
if(req.getParameter("city") != null){
prepareSql.append(" city,");
}
if(req.getParameter("zip") != null){
prepareSql.append(" zip,");
}
if(req.getParameter("country") != null){
prepareSql.append(" country,");
}
if(req.getParameter("email") != null){
prepareSql.append(" email,");
}
// Deleting the Coma at the end of an entity.
int sbLength = prepareSql.length();
prepareSql.deleteCharAt(sbLength - 1);

prepareSql.append(" from Personal where immat = " +
Integer.parseInt(req.getParameter("immat")));
return prepareSql.toString();

Second I pass this string to a method thru a variable
"sql" and execute this statement.

stmt.executeQuery(sql);

To my information I did a System.out.println(sql);
and I got the result "Select name, zip, email from
Personal where immat = 500103"

I get the error "The column name immat not found." as
the SQL Execption.

I executed the same statement in the psql command line
it was executing it and displaying the record.

Can someone explain me what wrong I had made. I had
also attached the codes for your reference.

Thanks in advance.
Domnic

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Attachment Content-Type Size
DBDataHandler.java application/octet-stream 2.1 KB
HTMLViewGenerator2.java application/octet-stream 1.7 KB
HTMLViewHandler2.java application/octet-stream 2.1 KB

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Rich Cullingford 2003-07-17 16:46:01 setFetchSize()
Previous Message Paul Thomas 2003-07-17 16:13:33 Re: Prepared Statements