Govt Exams
Type erasure is a mechanism where the Java compiler removes all generic type information during compilation, converting generic code to its raw type equivalent.
A SQLException (specifically a SQLNonTransientConnectionException as a subclass) is thrown when operations are attempted on a closed Connection. SQLException is the general exception for database access errors.
TYPE_SCROLL_INSENSITIVE allows movement in both directions (previous, next, absolute) but doesn't reflect changes made to the database after the ResultSet was created. TYPE_SCROLL_SENSITIVE would reflect changes.
PreparedStatement pre-compiles the query and allows parameter binding, reducing overhead and improving performance for repeated executions. It also prevents SQL injection.
DatabaseMetaData (obtained from Connection.getMetaData()) provides information about the entire database like tables, columns, keys, and supported features.
try-with-resources automatically closes AutoCloseable resources (Connection, Statement, ResultSet), preventing connection leaks elegantly.
byte[] should map to BLOB (Binary Large Object), not CHAR. CHAR is for single character types.
wasNull() returns true if the last retrieved value was NULL in the database, checked after calling a getter method like getString() or getInt().
Connection objects are not thread-safe. Each thread should obtain its own Connection from a thread-safe connection pool to avoid race conditions.
setMaxRows() limits the number of rows returned by executeQuery(), useful for memory management when dealing with large result sets.