Entrance Exams
Govt. Exams
CallableStatement is specifically designed for stored procedures, supporting registerOutParameter() for output parameters and getMoreResults() for multiple result sets.
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.
When Class.forName() cannot locate the driver class, it throws ClassNotFoundException, indicating the driver JAR is not in the classpath.
Unclosed connections remain allocated and unavailable for other operations, eventually exhausting the connection pool and causing connection exhaustion errors.
Connection pooling maintains a pool of reusable connections, reducing the overhead of creating new connections for each request, improving application performance.
The execute() method returns a boolean and can handle multiple result sets via getResultSet(), getUpdateCount(), and getMoreResults() methods.
Type 4 drivers are pure Java implementations that directly communicate with the database, making them platform-independent and most portable.
addBatch() and executeBatch() methods allow multiple SQL statements to be grouped and executed together, reducing network traffic and improving performance.