• 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
Marshal
Posts: 35279
384
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
Marshal
Posts: 35279
384
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
Saloon Keeper
Posts: 4031
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic