Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Prepared Statement

 
Manikanth Valluru
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This statement has a SetString method.I want to know to which it is going to Set.
My code is below:
String sqlSelect="select username,password from userinfo where username=? and password=?";
pst=conn.prepareStatement(sqlSelect);
pst.setString(1,uinfo.getUserName());
pst.setString(2,uinfo.getPassWord());
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35977
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a forum just for JDBC questions. I'll move this there for you.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35977
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manikanth,
It sets them in the order specified. So username is first and password is second. Or am I missing the point of your question?
 
Manikanth Valluru
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was confused about from where the Prepared Statements sets the values is it from the user or from the database.
manikanth
 
Scott Selikoff
author
Bartender
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
User. It reads the ?'s in order they are in the SQL query string. The database does not rearrange them. Actually a better way to say it is that the database doesn't even see the prepared statement, it just sees the finalized SQL string with the values filled in.
[ October 04, 2007: Message edited by: Scott Selikoff ]
 
Manikanth Valluru
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now I understood it.
thank you
Manikanth
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!