column not found ! - Mailing list pgsql-jdbc

From Savio Domnic
Subject column not found !
Date
Msg-id 20030717162004.98288.qmail@web40513.mail.yahoo.com
Whole thread Raw
Responses Re: column not found !
List 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

pgsql-jdbc by date:

Previous
From: Paul Thomas
Date:
Subject: Re: Prepared Statements
Next
From: Rich Cullingford
Date:
Subject: setFetchSize()