Java-JDBC Statement Vs PreparedStatement
Posted on 2004-03-31
I'm using Java JDBC Statement to do select/insert/update data.
All my stmt.executeQuery()/stmt.executeUpdate() are executed
only once. (not in a loop) I have around 2000 of these Statements
in my application.Its a web based project and deployed into IBM WebSphere.
From the readbility point of view I hate my half page SQL string statement
and also lot of String concatenation or stringbuffer.append().
I understand that using PreparedStatement will decrease performance
since all my SQL statements are executed only once. But it gives the
elegant look and no string/stringbuffer operations. ok
Can I solve the issue of readability and avoiding String concatenation by
using PreparedStatement but without loosing the performance.
Is there anywhere (jdbc or driver or database) I can set something (some flag or variable)
so that I can use preparedstatement (thus good readbility, no more string operations)
and still maintaining same performance as Statement ???
Thanks in advance.