1 / 9

JDBC – some remarks

JDBC – some remarks. Statement vs. PreparedStatement. Statement vs. PreparedStatement. PreparedStatement – more efficient when query executed repeatedly (possibly with different parameter values) the server creates the execution plan only once. Not always – depends on implementation

lala
Télécharger la présentation

JDBC – some remarks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JDBC – some remarks

  2. Statement vs. PreparedStatement

  3. Statement vs. PreparedStatement • PreparedStatement– more efficient when query executed repeatedly (possibly with different parameter values) • the server creates the execution plan only once. • Not always – depends on implementation • Statement – threat of SQL injection

  4. Closing JDBC resources • conn.close() may not close the connection if the connection has some JDBC resources open. Don’t rely on assumption that conn.close() should close them !!! • => rs.close(); stmt.close(); conn.close()

  5. Comparison of access methods

  6. Connection and ResultSet • Don’t share connection among multiple threads • ResultSetrs = stmnt.executeQuery(); • rs may reference an object owned by the JDBC driver => danger of a deadlock • Another reason why connection shall not be shared: • The transaction is bound to the connection

More Related