A widely asked Java interview questions in most of the Java interview.
So one can start the answer as follows: –
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:
Also see the following video on Java Builder Design Pattern as follows: –
Know more on Java interview questions
Get more on Java interview questions from author’s blog.