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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prepared Statement
 
Similar Threads
servlet program , sql error in coding, helpppp
prepared statement
How to configure Bonecp in java project without breaking connection when more than connection
how to prevent sql injection
Cannot insert data into table and throwing null message at Exception