Top X Jdbc Interview Questions Answers For Coffee Programmer

Advertisement

Masukkan script iklan 970x90px

Top X Jdbc Interview Questions Answers For Coffee Programmer

Senin, 15 Juni 2020

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 2 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 or thus JDBC performance tips. In this article I cause got summarized few often asked questions inwards JDBC, they ranges from slowly 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 for sure helps.

 

10 JDBC Interview enquiry reply inwards Java

JDBC Questions are integral business office of whatsoever Java interview Top 10 JDBC Interview questions answers for Java programmerHere is my listing of often asked JDBC enquiry inwards Java, I cause got tried to supply 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 thus delight percentage amongst us.


>

Question 1:  What is JDBC?
Answer : One of the kickoff 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 amongst database. For this nosotros demand database specific JDBC drivers. Some fourth dimension this likewise resultant inwards followup questions similar Difference betwixt type 2 in addition to type four 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 amongst database.
·          Make Connection: Next measuring is acquire connectedness from the database using connectedness object, which is used to post SQL contestation likewise in addition to acquire resultant dorsum from the database.
·          Get Statement object: From connectedness object nosotros tin acquire contestation object which is used to query the database
·          Execute the Query:Using contestation object nosotros execute the SQL or database query in addition to acquire resultant laid from the query.
·          Close the connection:After getting resultset in addition to all required functioning performed the terminal measuring should endure closing the database connection.
For consummate code illustration you lot tin likewise refere Java programme to connect to Oracle database


Question 3: What is the hateful of “dirty read“ inwards database?
Answer : This variety of JDBC interview enquiry is asked on 2 to four years sense Java programmer, they are expected to familiar amongst database transaction in addition to isolation degree etc. As the cite it self select the pregnant of muddied read “read the value which may or may non endure correct”. inwards database when 1 transaction is executing in addition to changing or thus champaign value same fourth dimension or thus some other transaction comes in addition to read the alter champaign value earlier kickoff transaction commit or rollback the value ,which elbow grease 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 select business office inwards distributed transaction process. In elementary give-and-take nosotros tin sympathise similar if whatsoever transaction is executing in addition to it volition trial multiple database in addition to thus 2 stage commit volition endure used to brand all database synchronized amongst each other.

In 2 stage commit, commit or rollback is done past times 2 phases:
1.       Commit asking phase: inwards this stage principal physical care for or coordinator physical care for select 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 thus they exceed away ahead for adjacent phase. And if “No “then rollback is performed.
2.       Commit phase: according to vote if all the votes are yes in addition to thus commit is done.

Similarly when whatsoever transaction changes multiple database afterward 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 ascendancy otherwise rollback is done .

Question 5: What are dissimilar types of Statement?
Answer :  This is or thus 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 resultant from database, in addition to nosotros acquire contestation object from connectedness object.

There are 3 types of statement:
1. Statement: it’s a ordinarily used for getting information from database useful when nosotros are using static SQL contestation at runtime. it volition non select whatsoever parameter.
              Statement   stmt = conn.createStatement( );
      ResultSet rs = stmt.executeQuery();

2. PreparedStatement: when nosotros are using same SQL contestation multiple fourth dimension its is useful in addition to it volition select parameter at runtime.
   
              String SQL = "Update stock SET limit = ? WHERE stockType = ?";
      PreparedStatement  pstmt = conn.prepareStatement(SQL);
      ResultSet rs = pstmt.executeQuery();

To acquire to a greater extent than virtually PreparedStatement, see  What is PreparedStatement inwards Java in addition to Benefits

3. Callable Statement: when nosotros desire to access stored procedures in addition to thus callable contestation are useful in addition to they likewise select runtime parameter. It is called similar this
           
      CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
      ResultSet rs = cs.executeQuery();


Question 6: How cursor plant inwards scrollable resultant set?
Answer : Another  tough JDBC Interview question, non many Java programmer knows virtually using Cursor inwards Java.
in JDBC 2.0 API novel characteristic is added to motion cursor inwards resultset backward forwards in addition to likewise inwards a item row .
There are 3 constant define inwards resultant laid past times which nosotros tin motion cursor.
·          TYPE_FORWARD_ONLY: creates a nonscrollable resultant set, that is, 1 inwards which the cursor moves entirely forward
·          TYPE_SCROLL_INSENSITIVE : a scrollable resultant laid does non reflects changes that are made to it spell it is open
·          TYPE_SCROLL_SENSITIVE: a scrollable resultant set  reflects changes that are made to it spell it is open


Question 7:  What is connectedness pooling?
Answer : This is likewise 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 amongst database .In this machinery customer are non required every fourth dimension brand novel connectedness in addition to and thus interact amongst database instead of that connectedness objects are stored inwards connectedness puddle in addition to customer volition acquire it from there. thus it’s a best agency to percentage a server resources amidst the customer in addition to heighten the application performance. If you lot purpose Spring framework, in addition to thus you lot tin likewise refer How to setup JDBC Connection Pool using Spring inwards Java


Question 8: What produce you lot hateful past times mutual frigidity backup, hot backup?
Answer : This enquiry is non straight related to JDBC but or thus 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 organisation inwards JDBC
Answer : One to a greater extent than tough JDBC enquiry to sympathise 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 2 user are reading the same tape in addition to thus in that location is no number but what if users are updating the tape , inwards this instance changes done past times kickoff user is gone past times 2nd user if he likewise update the same tape .so nosotros demand or thus type of locking thus no lost update.

Optimistic Locking: optimistic locking lock the tape entirely when update select 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 entirely 1 contestation object when using JDBC-ODBC Bridge.

That’s all on this listing of 10 JDBC Interview enquiry amongst 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