Govt. Exams
Entrance Exams
getMetaData() on ResultSet returns ResultSetMetaData which provides column information. getColumnCount() and getColumnName() are methods of ResultSetMetaData used to retrieve structure details.
DataSource with connection pooling frameworks (HikariCP, C3P0) efficiently manages connections by reusing them, reducing overhead. Direct getConnection() calls create new connections each time, which is inefficient for high concurrency.
executeBatch() behavior on failure varies by database and driver. BatchUpdateException is thrown, containing update counts for each statement. Explicit transaction control is recommended.
If query execution itself is slow (5 seconds), the bottleneck is in database operations, not data transfer. Increasing setFetchSize() only optimizes data retrieval, not query execution.
CallableStatement is specifically designed for stored procedures, supporting registerOutParameter() for output parameters and getMoreResults() for multiple result sets.
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.