Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

JDBC%20Interview%20Questions%20and%20Answers

Question: How can you use PreparedStatement?
Answer:

This special type of statement is derived from class Statement. If you need a Statement object to execute many times, it will normally make sense to use a PreparedStatement object instead. 

The advantage to this is that in most cases, this SQL statement will be sent to the DBMS right away, where it will be compiled. As a result, the PreparedStatement object contains not just an SQL statement, but an SQL statement that has been precompiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement's SQL statement without having to compile it first.
PreparedStatement updateSales = con.prepareStatement("UPDATE EMPLOYEE SET SAL=? WHERE EMP_ID=?");
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook