Re: column not found ! - Mailing list pgsql-jdbc

From Csaba Nagy
Subject Re: column not found !
Date
Msg-id 1058460583.24769.232.camel@coppola.ecircle.de
Whole thread Raw
In response to column not found !  (Savio Domnic <saviodomnic@yahoo.com>)
List pgsql-jdbc
For the error you get, I really can't think of anything else than the
field is really not there from the application side, and it's there on
the psql side.
This can happen if either of them started a transaction before creating
the table or adding that field, and didn't commit yet. In this case they
would see 2 different snapshots of the database, in one of them the
field exists, in the other doesn't... this is just a guess.

But why don't you use a prepared statement which gets all the fields,
and just display the requested ones ? Also see the previous threads
about directly setting input parameters from user input being dangerous.

Cheers,
Csaba.


On Thu, 2003-07-17 at 18:20, Savio Domnic wrote:
> 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
> ----
>

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html



pgsql-jdbc by date:

Previous
From: Rich Cullingford
Date:
Subject: setFetchSize()
Next
From: Raja Sekhar Paidi
Date:
Subject: ojb_hl_seq table access denied