Top Ten Jdbc Interview Questions Answers For Coffee Programmer
Sunday, June 24, 2018
Add Comment
JDBC Interview Question in addition to Answer
JDBC Questions are integral business office of whatsoever Java interview, I cause got non seen whatsoever Java Interview which is completed without asking unmarried JDBC Interview question, in that location are ever at to the lowest degree 1 or ii enquiry from JDBC API. Some of the pop questions similar Why you lot should purpose PreparedStatement inwards Java, Difference betwixt PreparedStatement and CallableStatement in Java in addition to few questions is related to improving performance of JDBC layer past times applying around JDBC performance tips. In this article I cause got summarized few often asked questions inwards JDBC, they ranges from tardily to hard in addition to beginner to advanced. Questions similar distributed transaction management in addition to 2 stage commit is tough to reply until you lot cause got existent sense but to a greater extent than often than non asked inwards diverse J2EE interviews. This is non an extensive listing of JDBC enquiry answers but practicing or revising this enquiry earlier going to whatsoever Java interview sure as shooting helps.
10 JDBC Interview enquiry reply inwards Java
Here is my listing of often asked JDBC enquiry inwards Java, I cause got tried to render reply to most of question. If you lot cause got whatsoever interesting JDBC enquiry which you lot cause got faced in addition to non inwards this listing in addition to therefore delight portion alongside us.
>
Question 1: What is JDBC?
Answer : One of the start JDBC interview enquiry inwards most of interviews. JDBC is coffee database connectivity every bit cite implies it’s a coffee API for communicating to relational database, API has coffee classes in addition to interfaces using that developer tin easily interact alongside database. For this nosotros demand database specific JDBC drivers. Some fourth dimension this every bit good outcome inwards followup questions similar Difference betwixt type 2 in addition to type iv JDBC drivers. See the link for answer.
Question 2: What are the principal steps inwards coffee to brand JDBC connectivity?
Answer : Another beginner degree JDBC Interview question, to a greater extent than often than non asked on telephonic interviews. Here are principal steps to connect to database.
· Load the Driver: First measuring is to charge the database specific driver which communicates alongside database.
· Make Connection: Next measuring is acquire connectedness from the database using connectedness object, which is used to post SQL disceptation every bit good in addition to acquire outcome dorsum from the database.
· Get Statement object: From connectedness object nosotros tin acquire disceptation object which is used to query the database
· Execute the Query:Using disceptation object nosotros execute the SQL or database query in addition to acquire outcome laid from the query.
· Close the connection:After getting resultset in addition to all required functioning performed the concluding measuring should last closing the database connection.
For consummate code instance you lot tin every bit good refere Java programme to connect to Oracle database
Question 3: What is the hateful of “dirty read“ inwards database?
Answer : This form of JDBC interview enquiry is asked on 2 to iv years sense Java programmer, they are expected to familiar alongside database transaction in addition to isolation degree etc. As the cite it self bring the important of dingy read “read the value which may or may non last correct”. inwards database when 1 transaction is executing in addition to changing around champaign value same fourth dimension around some other transaction comes in addition to read the alter champaign value earlier start transaction commit or rollback the value ,which crusade invalid value for that field, this scenario is known every bit dirty read.
Question 4: What is 2 stage commit?
Answer : This is 1 of the most pop JDBC Interview enquiry in addition to asked at advanced level, to a greater extent than often than non to senior Java developers on J2EE interviews. Two stage commit is used inwards distributed surroundings where multiple physical care for pick out business office inwards distributed transaction process. In uncomplicated discussion nosotros tin empathize similar if whatsoever transaction is executing in addition to it volition outcome multiple database in addition to therefore ii stage commit volition last used to brand all database synchronized alongside each other.
In ii stage commit, commit or rollback is done past times ii phases:
1. Commit asking phase: inwards this stage principal physical care for or coordinator physical care for pick out vote of all other physical care for that they are consummate their physical care for successfully in addition to create to commit if all the votes are “yes” in addition to therefore they move out ahead for side past times side phase. And if “No “then rollback is performed.
2. Commit phase: according to vote if all the votes are yes in addition to therefore commit is done.
Similarly when whatsoever transaction changes multiple database subsequently execution of transaction it volition number pre commit command on each database in addition to all database post acknowledgement in addition to according to acknowledgement if all are positive transaction volition number the commit dominance otherwise rollback is done .
Question 5: What are unlike types of Statement?
Answer : This is around other classical JDBC interview question. Variants are Difference betwixt Statement, PreparedStatemetn in addition to CallableStatement inwards Java. Statement object is used to post SQL query to database in addition to acquire outcome from database, in addition to nosotros acquire disceptation object from connectedness object.
There are 3 types of statement:
1. Statement: it’s a normally used for getting information from database useful when nosotros are using static SQL disceptation at runtime. it volition non pick out whatsoever parameter.
Statement stmt = conn.createStatement( );
ResultSet rs = stmt.executeQuery();
2. PreparedStatement: when nosotros are using same SQL disceptation multiple fourth dimension its is useful in addition to it volition pick out parameter at runtime.
String SQL = "Update stock SET limit = ? WHERE stockType = ?";
PreparedStatement pstmt = conn.prepareStatement(SQL);
ResultSet rs = pstmt.executeQuery();
To larn to a greater extent than nearly PreparedStatement, see What is PreparedStatement inwards Java in addition to Benefits
3. Callable Statement: when nosotros desire to access stored procedures in addition to therefore callable disceptation are useful in addition to they every bit good pick out runtime parameter. It is called similar this
ResultSet rs = cs.executeQuery();
Question 6: How cursor industrial plant inwards scrollable outcome set?
Answer : Another tough JDBC Interview question, non many Java programmer knows nearly using Cursor inwards Java.
in JDBC 2.0 API novel characteristic is added to movement cursor inwards resultset backward frontward in addition to every bit good inwards a detail row .
There are 3 constant define inwards outcome laid past times which nosotros tin movement cursor.
· TYPE_FORWARD_ONLY: creates a nonscrollable outcome set, that is, 1 inwards which the cursor moves exclusively forward
· TYPE_SCROLL_INSENSITIVE : a scrollable outcome laid does non reflects changes that are made to it piece it is open
· TYPE_SCROLL_SENSITIVE: a scrollable outcome set reflects changes that are made to it piece it is open
Question 7: What is connectedness pooling?
Answer : This is every bit good 1 of the most pop enquiry asked during JDBC Interviews. Connection pooling is the machinery past times which nosotros reuse the recourse similar connectedness objects which are needed to brand connectedness alongside database .In this machinery customer are non required every fourth dimension brand novel connectedness in addition to and therefore interact alongside database instead of that connectedness objects are stored inwards connectedness puddle in addition to customer volition acquire it from there. therefore it’s a best means to portion a server resources amid the customer in addition to get upwards the application performance. If you lot purpose Spring framework, in addition to therefore you lot tin every bit good refer How to setup JDBC Connection Pool using Spring inwards Java
Question 8: What create you lot hateful past times mutual frigidness backup, hot backup?
Answer : This enquiry is non straight related to JDBC but around fourth dimension asked during JDBC interviews. Cold dorsum is the backup techniques inwards which backup of files are taken earlier the database restarted. In hot backup backup of files in addition to tabular array is taken at the same fourth dimension when database is running. H5N1 warm is a recovery technique where all the tables are locked in addition to users cannot access at the fourth dimension of backing upwards data.
Question 9: What are the locking organization inwards JDBC
Answer : One to a greater extent than tough JDBC enquiry to empathize in addition to prepare. There are 2 types of locking inwards JDBC past times which nosotros tin grip multiple user number using the record. if ii user are reading the same tape in addition to therefore in that location is no number but what if users are updating the tape , inwards this instance changes done past times start user is gone past times minute user if he every bit good update the same tape .so nosotros demand around type of locking therefore no lost update.
Optimistic Locking: optimistic locking lock the tape exclusively when update pick out place. Optimistic locking does non purpose exclusive locks when reading
Pessimistic locking: inwards this tape are locked every bit it selects the row to update
Question 10: Does the JDBC-ODBC Bridge back upwards multiple concurrent opened upwards statements per connection?
Answer: No, nosotros tin opened upwards exclusively 1 disceptation object when using JDBC-ODBC Bridge.
That’s all on this listing of 10 JDBC Interview enquiry alongside answer. As I said JDBC API in addition to in that location concepts are integral business office of whatsoever Java interview in addition to in that location is ever atleast 1 enquiry from JDBC. Since most application uses datbase inwards backend, JDBC becomes critical for whatsoever Java developer.
Further Learning
JSP, Servlets in addition to JDBC for Beginners: Build a Database App
Complete JDBC Programming Part 1 in addition to 2
20 software pattern in addition to pattern pattern enquiry for Java programmer
0 Response to "Top Ten Jdbc Interview Questions Answers For Coffee Programmer"
Post a Comment