JDBC Interview inquiry forms 1 of the of import department inwards Java Interviews. Similar to multithreading, Collection framework together with Garbage collection interview question, JDBC inquiry must move prepared past times whatever Java programmer. Most of questions from JDBC or Java database connectivity comes from API together with basic architecture of JDBC which equally good involves JDBC drivers. Influenza A virus subtype H5N1 proficient agreement of JDBC API along with database basics similar transactions equally good assist to do good inwards JDBC interviews. I own got collected some of frequently asked JDBC Interview question for quick reference. This volition assist to revise some of import JDBC concepts together with equally good orbit a peril to explore JDBC API to newcomers. If you lot own got whatever other JDBC interview question, which has been asked to you lot or friends, together with you lot intend it’s proficient to portion alongside Java community thus delight portion with us. Let's run into my eleven questions from JDBC, non thus tough but worth preparing.
12 JDBC Interview Questions with Answers
Here is my listing of interview questions from JDBC. This listing contains questions cast JDBC drivers, PreparedStatement, CallableStatement, JDBC Connection pool, SQL Date together with Timestamp API, ResultSet together with RowSet concepts together with couplet of JDBC inquiry from practical experience.
Question 1 : Difference betwixt SQL Date together with java.util.Date inwards Java
Answer : This is 1 of JDBC Questions which I similar to ask, because knowing how to correctly shop together with retrieve appointment inwards a database is often confusing for novel developers together with its rattling critical for whatever application. Main divergence betwixt SQL information i.e. java.sql.Date together with util appointment i.e. java.util.Date is that SQL Date alone contains appointment work together with non fourth dimension work but util appointment contains both appointment together with fourth dimension part. See SQL Date vs Util Date inwards Java for to a greater extent than differences betwixt them.
Question 2: What is do goodness of using PreparedStatement inwards Java
Answer : Another wonderful JDBC interview inquiry which is rattling pop on telephonic equally good equally on early on circular of Java Interviews. There are several benefits of using PreparedStatement piece querying database from Java programme e.g. meliorate surgical operation together with prevents from SQL Injection. I advise to read Why work PreparedStatement inwards Java for to a greater extent than benefits together with details on JDBC PreparedStatement.
Question 3: What is JDBC database Connection Pool? How to setup inwards Java?
Answer : I own got ever seen at to the lowest degree 1 inquiry related to database connecter puddle inwards JDBC Interview e.g. do goodness of using JDBC Connection pool. Well JDBC connecter puddle maintains puddle of JDBC connecter which is used past times application to query database. Since JDBC connecter are expensive it accept fourth dimension to create them which tin orbit notice irksome response fourth dimension of server if created during asking time. Creating them on application start-up together with reusing them number inwards meliorate performance. See How to setup JDBC Connection Pool inwards Java using Spring for to a greater extent than details on JDBC connecter puddle together with benefits it offer.
Question 4: What is divergence betwixt type 2 together with type four JDBC drivers inwards Java
Answer : This JDBC Interview inquiry is equally erstwhile equally Vector vs ArrayList or Hashtable vs HashMap. I recollect questions almost JDBC ODBC drivers asked during almost every fresher aeroplane interview. Key divergence betwixt type 2 together with type four JDBC driver is that you lot only demand to include JAR file of JDBC driver inwards your classpath to connect database. See this link for to a greater extent than difference betwixt type 2 together with type four JDBC drivers.
Question 5: What is divergence betwixt java.sql.Time together with java.sql.TimeStamp inwards Java
Answer : This JDBC questions is similar to before JDBC interview inquiry java.sql.Date vs java.util.Date. Main divergence is that java.sql.Time degree doesn't comprise whatever appointment information on it piece java.sql.TimeStamp contains appointment information. See 4 divergence betwixt Time together with Timestamp inwards Java JDBC for to a greater extent than differences.
Question 6: What happens if nosotros telephone telephone resultSet.getInt(0) when Select query number only own got 1 column of integer type?
Answer : This is 1 of the tricky Java question which comes from JDBC. you lot may intend that it volition furnish outset column equally integer from Query number laid but unfortunately it doesn't. It throws InvalidColumnIndexException inwards JDBC because index for getXXX() or setXXX() inwards JDBC starts with 1. See How to ready InvalidColumnIndexException inwards JDBC for to a greater extent than details on this JDBC interview question.
Question 7: What is divergence betwixt RowSet together with ResultSet inwards JDBC?
Answer : One of the pop JDBC interview inquiry right away days. RowSet extends ResultSet together with add together back upwards for JDBC API to Java edible bean cistron model. Main divergence of ResultSet together with RowSet is RowSet beingness connected together with disconnected, which is some other follow-up JDBC question. RowSet makes it slowly to work ResultSet but equally I said you lot alone similar to work it to larn do goodness of disconnected together with connected RowSet.
Question 8: What is work of setAutoCommit(false) inwards JDBC ?
Answer : This is 1 of the JDBC Interview inquiry I touched on Top 10 JDBC best practices for Java programmer. making setAutoCommit(false) saves a lot of surgical operation equally it doesn't commit transaction automatically subsequently each query together with nosotros do batch update. It allows you lot to guide hold it using commit() together with rollback(). This has number inwards impressive surgical operation gain inwards DAO layer.
Question 9: How to telephone telephone stored physical care for from JDBC inwards Java?
Answer : This JDBC Interview inquiry is some other 1 you lot tin orbit notice add together on whatever often asked listing together with only can't afford non to prepare. Mostly asked to Java developers with 2 to four years experience. In its simplicity you lot tin orbit notice only say that CallableStatement is used to telephone telephone stored procedure, which may atomic number 82 questions similar how do you lot move past times parameters to stored physical care for from Java or difference betwixt IN together with OUT parameters inwards JDBC etc. It's worth to gear upwards this JDBC inquiry inwards detail. By the agency IN parameter is used to move past times input to stored physical care for together with OUT parameter is used to shop output furnish from stored procedure. IF your stored physical care for furnish multiple values than you lot tin orbit notice equally good work ResultSet to traverse all results.
Question 10: What is divergence betwixt Connected together with disconnected RowSet inwards JDBC?
Answer : I own got seen this JDBC inquiry asked equally a follow-up inquiry of previous JDBC interview inquiry RowSet vs ResultSet. Main divergence betwixt connected together with disconnected RowSet inwards JDBC is that disconnected RowSet doesn't require JDBC Connection piece it's on disconnected state. This makes disconnected RowSet low-cal together with ideal to work inwards sparse clients, piece connected RowSet is only a wrapper some ResultSet. JDBCRowSet together with WebRowSet are 2 examples of connected RowSet while a CachedRowSet is an lawsuit of disconnected RowSet which caches information inwards memory. Ideal for pocket-size information laid together with sparse Java clients with pocket-size retentiveness human foot print.
Question 11: What is divergence betwixt Statement, PreparedStatement together with CallableStatement inwards Java?
Answer : One of the classical JDBC interview question. Main divergence betwixt Statement together with PreparedSatement is surgical operation together with avoiding SQL Injection equally nosotros own got seen inwards Benefits of using PreparedStatement inwards Java. While CallableStatement has rattling specific work inwards JDBC together with used to telephone telephone stored physical care for from Java program
That's all on these eleven JDBC Interview questions together with answers article. As I said many times, JDBC questions are of import work of whatever Java interview, allow it substance Java or J2EE Interview together with you lot only can't ignore it. Always gear upwards JDBC good plenty to respond whatever JDBC Interview inquiry to perform good inwards Java interviews.
Further Learning
JSP, Servlets together with JDBC for Beginners: Build a Database App
Complete JDBC Programming Part 1 together with 2
10 Tough substance Java Interview inquiry for practice
No comments:
Post a Comment