Entrance Exams
Govt. Exams
Statement interface is used to execute simple SQL queries without parameters and return results as ResultSet.
A SavePoint allows you to roll back part of a transaction without rolling back the entire transaction. You can create nested transactions by setting multiple savepoints and rolling back to specific ones.
ResultSetMetaData interface provides information about the columns returned in a ResultSet, such as getColumnName(), getColumnType(), getColumnCount(), etc. Obtained via rs.getMetaData().
executeBatch() returns an int array where each element represents the update count for the corresponding statement. A value of -3 (Statement.EXECUTE_FAILED) indicates failure for that statement.
The next() method returns false when there are no more rows available. It does not throw an exception or loop back; it simply indicates that there are no additional rows to traverse.
The wasNull() method checks if the last value retrieved from a CallableStatement was NULL. To get the return value, you typically use getInt(), getString(), etc., and then check wasNull().
The default isolation level depends on the specific database and JDBC driver configuration. Different databases have different defaults (MySQL is REPEATABLE_READ, Oracle is READ_COMMITTED).
PreparedStatement with parameterized queries is the most secure approach as it separates SQL logic from data. The database treats parameters as data, not executable code, preventing SQL injection.
CONCUR_UPDATABLE is the ResultSet concurrency type that allows the ResultSet to be updated. CONCUR_READ_ONLY prevents modifications.
Batch processing allows multiple SQL statements to be grouped and sent together using addBatch() and executeBatch() methods, improving performance by reducing network overhead.