C
C
click_f2016-12-02 16:29:26
Java
click_f, 2016-12-02 16:29:26

JDBC always try to use PreparedStatement?

Does it always make sense to try to put some operations in a PreparedStatement when, for example, we are working with a Batch? Is the work worth the candles spent on hardcoding?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2016-12-02
@click_f

It is best to use PreparedStatement if you are not using any ORM.
1) It's safe as it eliminates the possibility of SQL injection
2) It's type-safe - the java-way.
3) It's fast, in some types of jdbc drivers they are compiled into stored procedures on the database side (for example, in sybase / mssql and oracle) or into pseudocode on the java side, and they are also cached.
Use it wherever you can PreparedStatement - javarevisited.blogspot.ru/2012/08/top-10-jdbc-best...
and javarevisited.blogspot.ru/2012/03/why-use-prepared...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question