Posted in Java EE, JDBC

Statement vs. PreparedStatement in JDBC

Statement

PreparedStatement

for executing static SQL statements execute dynamic queries with parameter inputs
use String Concatenation to create the query and it can’t accept input parameters Use setter methods to set the input parameters for the query
Suitable for DDL  Suitable for DML
Slower Faster
  Prevent SQL Injection attacks
   
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s