Top Ten Jdbc Interview Questions Answers For Coffee Programmer

JDBC Interview Question in addition to Answer
JDBC Questions are integral operate of whatsoever Java interview,  I conduct maintain non seen whatsoever Java Interview which is completed without asking unmarried JDBC Interview question, at that topographic point are ever at to the lowest degree i or 2 enquiry from JDBC API. Some of the pop questions similar Why you lot should usage 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 conduct maintain summarized few oftentimes asked questions inwards JDBC, they ranges from slow to hard in addition to beginner to advanced. Questions similar distributed transaction management in addition to 2 stage commit is tough to respond until you lot conduct maintain 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 respond inwards Java

JDBC Questions are integral operate of whatsoever Java interview Top 10 JDBC Interview questions answers for Java programmerHere is my listing of oftentimes asked JDBC enquiry inwards Java, I conduct maintain tried to supply respond to most of question. If you lot conduct maintain whatsoever interesting JDBC enquiry which you lot conduct maintain faced in addition to non inwards this listing in addition to hence delight part amongst us.


>

Question 1:  What is JDBC?
Answer : One of the showtime JDBC interview enquiry inwards most of interviews. JDBC is coffee database connectivity every bit advert implies it’s a coffee API for communicating to relational database, API has coffee classes in addition to interfaces using that developer tin post away easily interact amongst 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 primary steps inwards coffee to brand JDBC connectivity?
Answer : Another beginner marking JDBC Interview question, to a greater extent than often than non asked on telephonic interviews. Here are primary 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 connexion from the database using connexion object, which is used to post SQL contention every bit good in addition to acquire outcome dorsum from the database.
·          Get Statement object: From connexion object nosotros tin post away acquire contention object which is used to query the database
·          Execute the Query:Using contention 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 terminal measuring should endure closing the database connection.
For consummate code instance you lot tin post away every bit good refere Java programme to connect to Oracle database


Question 3: What is the hateful of “dirty read“ inwards database?
Answer : This sort of JDBC interview enquiry is asked on 2 to iv years sense Java programmer, they are expected to familiar amongst database transaction in addition to isolation marking etc. As the advert it self pick out the pregnant of dingy read “read the value which may or may non endure correct”. inwards database when i transaction is executing in addition to changing around champaign value same fourth dimension around some other transaction comes in addition to read the modify champaign value earlier showtime 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 i 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 operate inwards distributed transaction process. In uncomplicated discussion nosotros tin post away sympathise similar if whatsoever transaction is executing in addition to it volition lawsuit multiple database in addition to hence 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 primary 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 hence they snuff it 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 hence 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 ascendancy otherwise rollback is done .

Question 5: What are dissimilar 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 contention object from connexion object.

There are 3 types of statement:
1. Statement: it’s a unremarkably used for getting information from database useful when nosotros are using static SQL contention 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 contention 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 close PreparedStatement, see  What is PreparedStatement inwards Java in addition to Benefits

3. Callable Statement: when nosotros desire to access stored procedures in addition to hence callable contention are useful in addition to they every bit good pick out runtime parameter. It is called similar this
           
      CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
      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 close using Cursor inwards Java.
in JDBC 2.0 API novel characteristic is added to motion cursor inwards resultset backward forwards in addition to every bit good inwards a item row .
There are 3 constant define inwards outcome laid past times which nosotros tin post away motion cursor.
·          TYPE_FORWARD_ONLY: creates a nonscrollable outcome set, that is, i inwards which the cursor moves entirely 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 connexion pooling?
Answer : This is every bit good i of the most pop enquiry asked during JDBC Interviews. Connection pooling is the machinery past times which nosotros reuse the recourse similar connexion objects  which are  needed to brand connexion amongst database .In this machinery customer are non required every fourth dimension brand novel connexion in addition to and hence interact amongst database instead of that connexion objects are stored inwards connexion puddle in addition to customer volition acquire it from there. hence it’s a best agency to part a server resources amidst the customer in addition to heighten the application performance. If you lot usage Spring framework, in addition to hence you lot tin post away every bit good refer How to setup JDBC Connection Pool using Spring inwards Java


Question 8: What create you lot hateful past times mutual frigidity 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. Influenza A virus subtype 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 arrangement 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 post away grip multiple user number using the record. if 2 user are reading the same tape in addition to hence at that topographic point is no number but what if users are updating the tape , inwards this instance changes done past times showtime user is gone past times minute user if he every bit good update the same tape .so nosotros demand around type of locking hence no lost update.

Optimistic Locking: optimistic locking lock the tape entirely when update pick out place. Optimistic locking does non usage 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 post away opened upwards entirely i contention 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 at that topographic point concepts are integral operate of whatsoever Java interview in addition to at that topographic point is ever atleast i 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 blueprint in addition to blueprint pattern enquiry for Java programmer

Komentar

Postingan populer dari blog ini

Fix Protocol As Well As Cause Messaging Interview Questions

How To Carve Upwards A Comma Separated String Inwards Java? Regular Aspect Example