Google News
logo
JDBC - Interview Questions
What are the benefits of PreparedStatement over Statement?
* The PreparedStatement performs faster as compare to Statement because the Statement needs to be compiled everytime we run the code whereas the PreparedStatement compiled once and then execute only on runtime.

* PreparedStatement can execute Parameterized query whereas Statement can only run static queries.

* The query used in PreparedStatement is appeared to be similar every time. Therefore, the database can reuse the previous access plan whereas, Statement inline the parameters into the String, therefore, the query doesn't appear to be same everytime which prevents cache reusage.
Advertisement