This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes PreparedStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "PreparedStatement " Watch "PreparedStatement " New topic


Sreeni Gundla

Joined: Dec 21, 2009
Posts: 7
PreparedStatement are pre compiled statements could you please let me know what it is.
xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 133
Precompiled :-

Below are the steps involved to execute normal query using Java.
1.Java code will transfer the query to database
2. Database will compile the query.
3. Database will execute the query.

For prepared statement, first time all three steps will take part but from 2nd time onwards, step 1 and 3 only takes part in execution. Step -2 will be eliminated.

But for statement all thee steps will take part in execution of a query. It means that prepared statement is pre-compiled. Due to this, prepared statement is better in view of performace and in view of sql injection both.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19651

Moving to JDBC.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: PreparedStatement
Similar Threads
Problem with quotes (escape characters)
error of missing values
Update query
How to insert a null into a timezone column