Govt Exams
setAutoCommit(false) disables automatic commit, allowing multiple statements to be part of single transaction. Manual commit() or rollback() must be called.
DriverManager.getConnection() is the standard method that takes URL, username, and password to establish a connection to the database.
Connection pooling maintains a pool of reusable database connections to improve performance and reduce overhead of creating new connections repeatedly.
The next() method moves the ResultSet cursor to the next row and returns true if a row exists, false if no more rows. It's essential for iterating through results.
PreparedStatement offers faster execution due to precompilation and prevents SQL injection through parameterized queries using placeholders (?).
PreparedStatement is used for precompiled SQL statements with parameters. It provides better performance and prevents SQL injection compared to Statement.
executeUpdate() returns an integer representing the number of rows affected by INSERT, UPDATE, or DELETE operations. executeQuery() returns ResultSet.
BufferedReader with readLine() processes the file line-by-line, maintaining a constant memory footprint regardless of file size. Options A, C, and D would attempt to load the entire 5GB file into memory, causing OutOfMemoryError. This is the standard approach for large file processing.
Java serialization requires all instance variables to be serializable or marked as transient. If a non-serializable object is encountered during serialization, NotSerializableException is thrown at runtime, not compile-time. There's no automatic conversion.
ObjectOutputStream and ObjectInputStream are specifically designed for object serialization and deserialization. They handle the complete object state preservation. Other options are either inefficient or unsuitable for preserving object state.