O'Reilly logo

Special Edition Using Java 2 Standard Edition by Geoff Friesen, Chuck Cavaness, Brian Keeton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Prepared Statements

Up to this point, a java.sql.Statement class has been used to execute the SQL statements against the database. This is not very efficient if you will be executing the same SQL statements more than a couple of times because the SQL statement must be compiled each time it is sent to the database. The database does not understand the SQL string and is not able to execute it in the string format. It must turn the SQL string into something that it can understand and execute.

The java.sql.PreparedStatement can help with this because it will compile the SQL statement one time and then you can send the PreparedStatement to the database without the database having to compile it each time. This increases performance because the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required