Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
equalizing a variable in an sql statement
Keshini Weerasuriya
Greenhorn
Posts: 24
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi...
I'm trying to equal an ID which is taken as user input in an sql staement as below..
int answer = Integer.parseInt(mainMenu.client);
ResultSet rs = st.executeQuery("select * from Client where CliId = answer ");
Give the error, java.sql.SQLException: ORA-00904: invalid column name
Pls help.. Tnx..
Keith Lynn
Ranch Hand
Posts: 2412
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It looks like the column name you listed was not found in the table. I'm not sure, but it may be case sensitive.
Mani Ram
Ranch Hand
Posts: 1140
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Also note that you have included the 'answer' variable with in the quotes. So the query that will be executed in the database will be
select * from Client where CliId = answer;
The proper way to build the query is
ResultSet rs = st.executeQuery("select * from Client where CliId = " + answer);
Another way is to use a PreparedStatement
String QUERY = "select * from Client where CliId = ?"; preparedStatement = connection.prepareStatement ( QUERY ); preparedStatement.setInt ( answer ); preparedStatement.executeQuery ( );
Mani
Quaerendo Invenietis
Keshini Weerasuriya
Greenhorn
Posts: 24
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Tnx Mani Ram.. Your method works.........
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
request.parameter
jstl sql action
HFEJB page 435
Need to perform wildcard search
Difference between Statement/Prepared statement?
More...