Sunday, December 4, 2011

Top 10 JDBC Interview Questions

1.what are different frequent JDBC classes or interfaces used in java code?
Connection,DriverManager,ResultSet,Statement,PreparedStatement,CallableStatement.
. 2.How do you load the JDBC driver class?.
Class.forName("DriverClass") is used load the driver class. whenever DriverClass is loaded with this, create a new instance of DriverClass and register the driver with DriverManager Class. Once Driver is registered, it is ready to create physical connections to a database using the Connection object.
3. What is connection pooling?.
as a creating a database connection is like an opening a socket connection to the remote machine, so this call is expensive. whenever we have to do CRUD operations(create, read, update and delete) on data to the database, the Connection object is used for this. creating a connection for each operation is expensive. To avoid this, at the Initial state(application startup), creating a pool of connections which are created and connected to the database. whenever a database operation is to needed by the application, the connection from the pool of connections are reused, once the operation is over, the connection is returned instead of closing(in case of normal connection) connection so that Database calls are reduced and nonperformance is increased.