Entrance Exams
Govt. Exams
setAutoCommit(false) disables auto-commit mode, allowing manual control over transactions through commit() and rollback() methods.
The correct JDBC connection sequence is: Class.forName() → DriverManager.getConnection() → Create Statement → Execute Query → Close resources.
PreparedStatement is used for parameterized queries with placeholders (?), which prevents SQL injection by separating SQL logic from data.
JdbcTemplate in Spring Framework automatically manages JDBC resources and is the recommended approach in modern applications.
FetchSize controls how many rows are fetched from the database at once, optimizing performance for large datasets.
executeBatch() with addBatch() reduces network round-trips and improves performance for bulk operations.
When rollback() is called without savepoints, all changes made since the last commit are undone and rolled back.
Direct concatenation of user input in SQL queries exposes the application to SQL injection attacks. PreparedStatement should be used instead.
next() returns false when the cursor is positioned beyond the last row, indicating no more rows available.
ResultSetMetaData provides column information directly from the ResultSet without additional queries.