Without Book Interview Questions and Answers | Online Test | Moct Test
Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Institute Training Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

JDBC Interview Questions and Answers

Ques 6. What are the steps involved in establishing a JDBC connection?

Ans. involves two steps: loading the JDBC driver and making the connection.

Is it helpful? Add Comment View Comments
Ques 7. How can you load the drivers?
Ans. Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ, you would load the driver with the following line of code:

Class.forName("jdbc.DriverXYZ");
Is it helpful? Add Comment View Comments
Ques 8. What will Class.forName do while loading drivers?
Ans. It is used to create an instance of a driver and register it with the
DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS.
Is it helpful? Add Comment View Comments
Ques 9. How can you make the connection?
Ans. To establish a connection you need to have the appropriate driver connect to the DBMS.
The following line of code illustrates the general idea:
String url = "jdbc:odbc:WithoutBook";
Connection con = DriverManager.getConnection(url, "Username", "Password");
Is it helpful? Add Comment View Comments
Ques 10. How can you create JDBC statements and what are they?
Ans. A Statement object is what sends your SQL statement to the DBMS. You simply create a Statement object and then execute it, supplying the appropriate execute method with the SQL statement you want to send. For a SELECT statement, the method to use is executeQuery. For statements that create or modify tables, the method to use is executeUpdate. It takes an instance of an active connection to create a Statement object. In the following example, we use our Connection object con to create the Statement object
Statement stmt = con.createStatement();
Is it helpful? Add Comment View Comments

Most helpful rated by users:

©2017 WithoutBook