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

prepared statement compilation.

nandireddy sreekantha reddy
Greenhorn

Joined: Dec 05, 2003
Posts: 4
i have used the sql statement in prepared statement like this
connection.preparestatement("update x set col="+name+" where empno="+emp);
what will happen if you write the prepared statement like this .
is this statement compiled once and pass the values from next time onwords
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8867
    
    8

You can invoke the execute methods on the same PreparedStatement object any number of times and the SQL is only compiled once. In your example you would not be able to change the values of name or emp as they would have been compiled into the statement when the PreparedStatement was created. You can create a variable in a statement by using a ?, then using PreparedStatement.setXXX() to change the value between executions. Read more about PreparedStatement in the Java Tutorial


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: prepared statement compilation.