Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Read the following program and describe what the program does write comments

ID: 3571711 • Letter: 2

Question

2. Read the following program and describe what the program does write comments in the program listing import java io import java.sql. public class Example public static void main(string args0 trow SQLException, IOException Class forName( 'oracle jdbe driver oracleDriver"). 2 catch (ClassNotFoundException ex) System.out.println("Driver could not be loaded"); String url jdbc: oracle:www.bookstore.com:3083"; Connection con; try con Drive Manager getConnection(url, userld, password); String sqlQuery "SELECT isbn, title FROM Books WHERE publisher MIT Press PreparedStatement stmt .prepare Statement(sqlQuery); ResultSet rs strmt.execute(Query(sqlQuery); String isbn, title; System out println( isbn title while (rs next0) isbn rs.getString(i); System out.println(isbn title)

Explanation / Answer

1) Registering a jdbc driver

2) Catch block to catch the exception if class is not found(means if try bloack is not successfull)

3) Basically a string it is basically used while opening a db connection

4) Creating a connection class reference

5) Opening a db connection

6) it is a sql query that select isbn title from book where publisher is mit press

7) Creating statement object for further executing query.

8) Executing query and store it in result set refrence.

9) iterating the result set to get the data (basically iterting the set of data we got after executing the query).

10) Catch block to catch the SQl exception if query is unsuccessfull

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote