









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










-^ Applications must^ •^ Create queries^ •^ Submit them to the DB^ •^ Process the results (usually a list)^ •^ Handle errors
Use PreparedStatement instead(precompiled) String query = "SELECT name FROM Sailors where rating = ?"; PreparedStatement st = conn.prepareStatement(query); // precompile st.setFloat(1, 0.1); ResultSet rs = st.executeQuery(); // process resultset rs for rating = 0.1 st.clearParameters(); st.setFloat(1, 0.2); ResultSet rs = st.executeQuery(); // process resultset rs for rating = 0.2 ... This is also called a^ dynamic SQL query.
thus^ we^ use executeUpdate() int^ numRows^ =^ pstmt.executeUpdate();
Matching Java and SQL Data Types
e)^ { connection.rollback(); }