JDBC Flashcards
7 cards from real 1Z0-819 practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 JDBC flashcards as text
Which method of `PreparedStatement` is used to execute a SQL INSERT and return the number of affected rows?
Answer: executeUpdate()
`executeUpdate()` executes DML statements (INSERT, UPDATE, DELETE) and returns the count of affected rows.
What does `Connection.setAutoCommit(false)` do in JDBC?
Answer: Begins a manual transaction requiring explicit commit or rollback
Setting autoCommit to false puts the connection into manual transaction mode where you must call `commit()` or `rollback()` explicitly.
Which `ResultSet` method moves the cursor to the next row and returns `false` when no more rows exist?
Answer: next()
`ResultSet.next()` advances the cursor one row forward and returns `false` when there are no more rows.
What exception is thrown by JDBC methods when a database access error occurs?
Answer: SQLException
`SQLException` is the checked exception thrown by virtually all JDBC API methods when a database or driver error occurs.
Which `DriverManager` method is used to obtain a database `Connection`?
Answer: DriverManager.getConnection(url, user, pass)
`DriverManager.getConnection(url, user, password)` is the standard JDBC entry point for obtaining a database connection.
In a `PreparedStatement`, what character is used as a placeholder for parameters?
Answer: ?
A question mark `?` serves as the positional placeholder in a `PreparedStatement` SQL string, set later via `setXxx()` methods.
Which interface should you use when you need to call a stored procedure in JDBC?
Answer: CallableStatement
`CallableStatement` extends `PreparedStatement` and is specifically designed to execute stored procedures via the `{call procedure_name(?)}` syntax.