Govt. Exams
Entrance Exams
Class.forName() is used to load the JDBC driver class dynamically and register it with the DriverManager. For example: Class.forName("com.mysql.cj.jdbc.Driver");
ResultSet interface represents the result set of a query. It contains the data returned from a database query and provides methods to access and traverse through the rows.
The correct method is getInt(int columnIndex) which retrieves an integer value from the ResultSet at the specified column index (1-based indexing).
Type 4 drivers (thin drivers) are pure Java drivers that communicate directly with the database using the database native protocol. They are platform-independent and do not require native code.
getString() method retrieves String values from ResultSet. getInt() gets integer values, and fetchString/readString are not valid JDBC methods.
SQLException is thrown for database-related errors including connection failures. ClassNotFoundException occurs when JDBC driver class is not found.
Type 4 (Thin) drivers are pure Java drivers, platform-independent, and don't require native code. They communicate directly with database using Java sockets.
The correct JDBC sequence is: 1) Load the JDBC driver, 2) Create connection, 3) Create statement, 4) Execute query, 5) Process results, 6) Close resources.
Statement interface is used to execute SQL queries. Connection is used to establish database connection, ResultSet holds query results, and Driver manages database connections.