Saturday, September 09, 2006

Java/JDBC Questions

I have prepared set of questions for Java/J2EE (may be helpful to test one's knowledge). Here, first comes the questions from JDBC.

I don't have time to type the answers here:-) Pl, find yourself by reading books or googling or by asking someone who had lost his life in java.

If unable to find answers anywhere, you can directly mail ( or scold) me via: manivannan.p (at) gmail.com

JDBC – Questions: Manivannan.P (at) gmail.com, 14th Aug, 2006.

[For Beginner/Advanced/A bit experts]


1. What are all the available types of JDBC drivers? Give example for each type.
2. Which one of the available drivers is better?
3. Give sample scenarios where you would choose each one.
4. Write a sample JDBC code to connect to any database.
5. What do you understand by Class.forName(“drivername”).newInstance() ? (give alternative syntax for this)
6. What is a Statement and a PreparedStatement?
7. What is the difference between Statement and PreparedStatement. Which one is advisable to use?
8. How will you execute a DML statement using JDBC?
9. How will you traverse the ResultSet?
10. What exception will you probably get when you have no data in Resultset?
11. How will you print Meta data of Resultset like column count, column names and etc.
12. How will you execute a stored procedure using JDBC?
13. How will you pass parameters to stored procedure using JDBC?
14. Can you give example code for using IN, OUT and INOUT parameters stored procedure using JDBC?
15. How will you capture the return value of a function using JDBC?
16. How will you print the warning message, error code, status generated by the database (while using JDBC)?
17. How will you catch/escalate the exception generated by the database?
18. How will you manage the concurrency while using JDBC? (Just write down a sample code)
19. Give example for managing transaction using JTA.
20. How will you make the Resultset become scrollable by back and forth?
20.a) Can you move the Resultset to a particular row absolutely or relatively?
21.b) Can you give an example for inserting/updating/deleting a specified row on ResultSet?
21. How will you apply concurrency for Resultset?
22. How will you refresh the Resultset, without repeating the code?
23. How will you send sql statements in bulk? [Batchupdates]
23.a) How will you capture & analyze the return value of BtachUpdate?
23.b) What is the limitation of BatchUpdate ?
23.c) What is the difference in using Stored procedure and BatchUpdate
24. Can you explain what is connection pooling & how it is implemented? [provide sample code for connection pooling and a client that uses it]
25. What are all the parameters you need to pass while configuring connection pooling?
26. Do you know about two-phase and three-phase commit, can you explain it?
27. How will you handle blob, clob fields using JDBC?
28. Can you write code for storing and retrieving an image file/ text file using JDBC? [hint: using blob and clob]
29. Can you tell any noticeable differences between JDBC1.0, JDBC2.0, JDBC3.0 APIs?


Disclaimer: The questions [or answers] presented here are purely based on my perspective alone. There may be number of alternative answers.

2 comments:

prabs said...

cool collection mani..

but java is not my cup of coffee.. :P

Manivannan P said...

Thanks prabs!
Yeah, I knew it :-)