Govt. Exams
Entrance Exams
Class.forName() is the standard way to load JDBC drivers. It dynamically loads the driver class.
PreparedStatement allows parameterized queries using placeholders (?) and prevents SQL injection attacks.
Statement interface is used to execute SQL queries. Connection creates statements, ResultSet holds results, and Driver manages connections.
commit() finalizes the transaction and persists all changes made since the last commit or rollback.
ClassNotFoundException is thrown when Class.forName() cannot locate the JDBC driver class.
DriverManager.getConnection() establishes a connection to the database and returns a Connection object.
executeUpdate() returns an int representing the number of rows affected by the SQL statement execution.
PreparedStatement pre-compiles SQL and uses parameterized queries, preventing SQL injection and improving performance.
Statement interface is used to execute simple SQL queries without parameters and return results as ResultSet.
The next() method returns false when there are no more rows available. It does not throw an exception or loop back; it simply indicates that there are no additional rows to traverse.