Saturday 5 November 2011

Java interview questions: - Describe JDBC and steps involved in the JDBC connection.

A widely asked  Java interview questions in most of the Java interview.

So one can start the answer as follows: -

Definition: -


JDBC is a set of Java API for executing SQL statements. This API consists of a set of classes and interfaces to enable programs to write pure Java Database applications

Steps in the JDBC connection: -

Step 1: Register the database driver by using:
Class.forName(\" driver class for that specific database\" );

Step 2: Now create a database connection using:
Connection con = DriverManager.getConnection(url,username,password);

Step 3: Now create a query using:
Statement stmt = Connection.Statement(\"select * from TABLE NAME\");

Step 4: Execute the query:
stmt.exceuteUpdate();

Also see the following video on Java Builder Design Pattern as follows: -



Know more on  Java interview questions

Regards,


Get more on Java interview questions from author’s blog.

No comments:

Post a Comment