Java interview questions: JDBC and its connection.

128 0 0
                                        

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 classs 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 rightside video on Java Builder Design Pattern : -

Know more on Java interview questions

Java interview questions: JDBC and its connection.Where stories live. Discover now