Re: Attribute 'name' not found ERROR for postgres and java
От | Steve Waldman |
---|---|
Тема | Re: Attribute 'name' not found ERROR for postgres and java |
Дата | |
Msg-id | 20010428161031.A18265@peanut-butter.mchange.com обсуждение исходный текст |
Ответ на | Attribute 'name' not found ERROR for postgres and java ("suhail sarwar" <sarwar@postmaster.co.uk>) |
Список | pgsql-novice |
Sarwar, Your problem is in either in your SQL syntax or in the use of prepared statement, depending on what you wanted to happen. The error you are seeing comes because "name" in your SQL statement is neither the SQL String literal 'name', nor any kind of variable or identifier Postgres knows about. Yes, it is the name of the column you are trying to insert in, but that does not help postgres figure out what you are trying to insert. If you intended to insert the literal 'name' into the table, modify your code like so: PreparedStatement stt = db.prepareStatement("INSERT INTO Test1 " + "VALUES (100, 'name', age)"); stt.executeUpdate(); If name is a variable which you intended to have inserted into the table, try this: String name = "Sarwar"; PreparedStatement stt = db.prepareStatement("INSERT INTO Test1 " + "VALUES (100 , ? , age)"); ps.setString(1, name); stt.executeUpdate(); Hope this helps, Steve On Sat, Apr 28, 2001 at 12:58:54PM +0100, suhail sarwar wrote: > Hi, > > I am getting this sql exception "Attribute 'name' not found" and I can't seem to figure it out at all. I have a java programthat creates a table in postgresql using a prepared statement and that bit works. Then I have added another preparedstatement to populate the table with values (see below): > PreparedStatement stt = db.prepareStatement("INSERT INTO Test1 " + "VALUES (100, name, age)"); > stt.executeUpdate(); > > There is a column in the table Test1 called name but it is unpopulated and the above code should insert the values. HoweverI get the sql exception attribute name not found. > > If I change 'name' in the above code to say 'neat' then the sql exception changes to "sql exception attribute 'neat notfound". > > Does anyone know what is happening. > > Any help is much appreciated. > > Regards > > Sarwar > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html
В списке pgsql-novice по дате отправления: