The PreparedStatement
is frequently used in loops because it allows to conveniently set parameters. A small optimization is possible
by setting constant parameters outside the loop or hard-coding them in the query whenever possible.
What is the potential impact?
- Performance: the unnecessary calls to the setter methods bring overhead.
- Sustainability: the extra overhead has a negative impact on the environment.