Skip site navigation (1) Skip section navigation (2)

Variables in SQL statements

From: "suhail sarwar" <sarwar(at)postmaster(dot)co(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Variables in SQL statements
Date: 2001-04-29 16:55:24
Message-ID: PM.3438.988563324@pmweb6.uk1.bibliotech.net (view raw or flat)
Thread:
Lists: pgsql-novice
Can I use a java variable in an SQL statement written in a java program?

I am trying to have user input for my java program which takes input variables from a user and inserts them into my postgresql database.

The problem is that at the moment I get an attribute not found error. Below is a snippit of the code:

...<<buffreredReader code here...>>...
String name = tKeyboard.readLine();
st.executeUpdate("INSERT INTO TEST13 " + "VALUES (name)");

The program compiles ok, but when run the program says attribute 'name' not found under SQL Exception. 

Any help is much appreciated.

Kind Regards

Sarwar

pgsql-novice by date

Next:From: Tom LaneDate: 2001-04-30 03:58:50
Subject: Re: take my index, please
Previous:From: suhail sarwarDate: 2001-04-29 15:00:04
Subject: Multiple SQL statements in a java program for postgresql DB

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group