---
title: "What is the difference between PreparedStatement and Statement in java?"  
description: "What is the difference between PreparedStatement and Statement in java?"  
author: "Anupam Mishra"  
published: 2015-11-03  
updated: 2020-09-17  
canonical: https://www.mindstick.com/interview/22881/what-is-the-difference-between-preparedstatement-and-statement-in-java  
category: "java"  
tags: ["java", "j2ee"]  
reading_time: 1 minute  

---

# What is the difference between PreparedStatement and Statement in java?

1.A statement is parsed and executed each time its call sent to database.\
2. A prepared statement may be parsed once and executed repeatedly with different parameters.\
\

## There are four steps for the execution of query:

1. Query is parsed\
2.Query is compiled.\
3. Query is optimized.\
4. Query is executed.

**In case of statement, the above four steps are performed every time. And in case of prepared statement the above three steps are performed once.**

\

## Answers

### Answer by Anupam Mishra

1.A statement is parsed and executed each time its call sent to database.\
2. A prepared statement may be parsed once and executed repeatedly with different parameters.\
\

## There are four steps for the execution of query:

1. Query is parsed\
2.Query is compiled.\
3. Query is optimized.\
4. Query is executed.

**In case of statement, the above four steps are performed every time. And in case of prepared statement the above three steps are performed once.**

\


---

Original Source: https://www.mindstick.com/interview/22881/what-is-the-difference-between-preparedstatement-and-statement-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
