aspose file tools*
The moose likes JDBC and the fly likes Prepared Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Prepared Statement " Watch "Prepared Statement " New topic
Author

Prepared Statement

Manikanth Valluru
Greenhorn

Joined: Jan 06, 2004
Posts: 4
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

Joined: May 26, 2003
Posts: 30768
    
156

We have a forum just for JDBC questions. I'll move this there for you.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30768
    
156

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

Joined: Jan 06, 2004
Posts: 4
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

Joined: Oct 23, 2005
Posts: 3710
    
    5

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 ]

My Blog: Down Home Country Coding with Scott Selikoff
Manikanth Valluru
Greenhorn

Joined: Jan 06, 2004
Posts: 4
now I understood it.
thank you
Manikanth
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Prepared Statement