Top Ten Jdbc Interview Questions Answers For Coffee Programmer
JDBC Interview Question as well as Answer
JDBC Questions are integral business office of whatever Java interview, I induce got non seen whatever Java Interview which is completed without asking unmarried JDBC Interview question, at that spot are ever at to the lowest degree ane or ii inquiry from JDBC API. Some of the pop questions similar Why y'all should role PreparedStatement inward Java, Difference betwixt PreparedStatement and CallableStatement in Java as well as few questions is related to improving performance of JDBC layer past times applying closed to JDBC performance tips. In this article I induce got summarized few oft asked questions inward JDBC, they ranges from tardily to hard as well as beginner to advanced. Questions similar distributed transaction management as well as 2 stage commit is tough to reply until y'all induce got existent sense but generally asked inward diverse J2EE interviews. This is non an extensive listing of JDBC inquiry answers but practicing or revising this inquiry earlier going to whatever Java interview surely helps.
10 JDBC Interview inquiry reply inward Java
Here is my listing of oft asked JDBC inquiry inward Java, I induce got tried to supply reply to most of question. If y'all induce got whatever interesting JDBC inquiry which y'all induce got faced as well as non inward this listing as well as therefore delight portion amongst us.
>
Question 1: What is JDBC?
Answer : One of the starting fourth dimension JDBC interview inquiry inward most of interviews. JDBC is coffee database connectivity every bit nurture implies it’s a coffee API for communicating to relational database, API has coffee classes as well as interfaces using that developer tin mail away easily interact amongst database. For this nosotros demand database specific JDBC drivers. Some fourth dimension this likewise termination inward followup questions similar Difference betwixt type 2 as well as type four JDBC drivers. See the link for answer.
Question 2: What are the principal steps inward coffee to brand JDBC connectivity?
Answer : Another beginner score JDBC Interview question, generally 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 connexion from the database using connexion object, which is used to mail SQL disputation likewise as well as acquire termination dorsum from the database.
· Get Statement object: From connexion object nosotros tin mail away acquire disputation object which is used to query the database
· Execute the Query:Using disputation object nosotros execute the SQL or database query as well as acquire termination laid from the query.
· Close the connection:After getting resultset as well as all required performance performed the terminal measuring should survive closing the database connection.
For consummate code instance y'all tin mail away likewise refere Java plan to connect to Oracle database
Question 3: What is the hateful of “dirty read“ inward database?
Answer : This sort of JDBC interview inquiry is asked on 2 to four years sense Java programmer, they are expected to familiar amongst database transaction as well as isolation score etc. As the nurture it self bring the pregnant of dingy read “read the value which may or may non survive correct”. inward database when ane transaction is executing as well as changing closed to plain value same fourth dimension closed to some other transaction comes as well as read the alter plain value earlier starting fourth dimension transaction commit or rollback the value ,which drive invalid value for that field, this scenario is known every bit dirty read.
Question 4: What is 2 stage commit?
Answer : This is ane of the most pop JDBC Interview inquiry as well as asked at advanced level, generally to senior Java developers on J2EE interviews. Two stage commit is used inward distributed environs where multiple physical care for choose business office inward distributed transaction process. In uncomplicated give-and-take nosotros tin mail away sympathise similar if whatever transaction is executing as well as it volition outcome multiple database as well as therefore ii stage commit volition survive used to brand all database synchronized amongst each other.
In ii stage commit, commit or rollback is done past times ii phases:
1. Commit asking phase: inward this stage principal physical care for or coordinator physical care for choose vote of all other physical care for that they are consummate their physical care for successfully as well as create to commit if all the votes are “yes” as well as therefore they give-up the ghost ahead for adjacent phase. And if “No “then rollback is performed.
2. Commit phase: according to vote if all the votes are yes as well as therefore commit is done.
Similarly when whatever transaction changes multiple database afterwards execution of transaction it volition number pre commit command on each database as well as all database mail acknowledgement as well as according to acknowledgement if all are positive transaction volition number the commit ascendance otherwise rollback is done .
Question 5: What are unlike types of Statement?
Answer : This is closed to other classical JDBC interview question. Variants are Difference betwixt Statement, PreparedStatemetn as well as CallableStatement inward Java. Statement object is used to mail SQL query to database as well as acquire termination from database, as well as nosotros acquire disputation object from connexion object.
There are iii types of statement:
1. Statement: it’s a ordinarily used for getting information from database useful when nosotros are using static SQL disputation at runtime. it volition non induce got whatever parameter.
Statement stmt = conn.createStatement( );
ResultSet rs = stmt.executeQuery();
2. PreparedStatement: when nosotros are using same SQL disputation multiple fourth dimension its is useful as well as it volition induce got parameter at runtime.
String SQL = "Update stock SET boundary = ? WHERE stockType = ?";
PreparedStatement pstmt = conn.prepareStatement(SQL);
ResultSet rs = pstmt.executeQuery();
To larn to a greater extent than virtually PreparedStatement, see What is PreparedStatement inward Java as well as Benefits
3. Callable Statement: when nosotros desire to access stored procedures as well as therefore callable disputation are useful as well as they likewise induce got runtime parameter. It is called similar this
ResultSet rs = cs.executeQuery();
Question 6: How cursor industrial plant inward scrollable termination set?
Answer : Another tough JDBC Interview question, non many Java programmer knows virtually using Cursor inward Java.
in JDBC 2.0 API novel characteristic is added to motion cursor inward resultset backward forwards as well as likewise inward a detail row .
There are iii constant define inward termination laid past times which nosotros tin mail away motion cursor.
· TYPE_FORWARD_ONLY: creates a nonscrollable termination set, that is, ane inward which the cursor moves alone forward
· TYPE_SCROLL_INSENSITIVE : a scrollable termination laid does non reflects changes that are made to it piece it is open
· TYPE_SCROLL_SENSITIVE: a scrollable termination set reflects changes that are made to it piece it is open
Question 7: What is connexion pooling?
Answer : This is likewise ane of the most pop inquiry 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 as well as and therefore interact amongst database instead of that connexion objects are stored inward connexion puddle as well as customer volition acquire it from there. therefore it’s a best agency to portion a server resources amid the customer as well as get upwards the application performance. If y'all role Spring framework, as well as therefore y'all tin mail away likewise refer How to setup JDBC Connection Pool using Spring inward Java
Question 8: What create y'all hateful past times mutual frigidity backup, hot backup?
Answer : This inquiry is non straight related to JDBC but closed to fourth dimension asked during JDBC interviews. Cold dorsum is the backup techniques inward which backup of files are taken earlier the database restarted. In hot backup backup of files as well as 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 as well as users cannot access at the fourth dimension of backing upwards data.
Question 9: What are the locking organisation inward JDBC
Answer : One to a greater extent than tough JDBC inquiry to sympathise as well as prepare. There are 2 types of locking inward JDBC past times which nosotros tin mail away handgrip multiple user number using the record. if ii user are reading the same tape as well as therefore at that spot is no number but what if users are updating the tape , inward this instance changes done past times starting fourth dimension user is gone past times 2nd user if he likewise update the same tape .so nosotros demand closed to type of locking therefore no lost update.
Optimistic Locking: optimistic locking lock the tape alone when update choose place. Optimistic locking does non role exclusive locks when reading
Pessimistic locking: inward 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 mail away opened upwards alone ane disputation object when using JDBC-ODBC Bridge.
That’s all on this listing of 10 JDBC Interview inquiry amongst answer. As I said JDBC API as well as at that spot concepts are integral business office of whatever Java interview as well as at that spot is ever atleast ane inquiry from JDBC. Since most application uses datbase inward backend, JDBC becomes critical for whatever Java developer.
Further Learning
JSP, Servlets as well as JDBC for Beginners: Build a Database App
Complete JDBC Programming Part 1 as well as 2
20 software pattern as well as pattern pattern inquiry for Java programmer
Belum ada Komentar untuk "Top Ten Jdbc Interview Questions Answers For Coffee Programmer"
Posting Komentar