22-01-25 ---------- Q)What are the system requirements at JDBC client side to perform CRUD operations with the database? 1)JDBC API 2)JDBC driver Note:- JDBC driver is different for a different DBMS. Q)What is JDBC Programming Model? DIAGRAM Requesting for database connection ---------------------------------------- =>Java application makes a static method call on java.sql.DriverManager class to get the database connection. Connection connection=DriverManager.getConnection("address of the database","username","password"); Note:- Object oriented representation of JDBC client's session with the database server is nothing but java.sql.Connection object. =>As long as the session is active, so long JDBC client can perform CRUD operations. creating the Statement object --------------------------------- =>java.sql.Statement object is the designatory object for submitting SQL statements from the JDBC client to the DBMS. =>By calling createStatement() method on the connection object, Statement object is created. Statement statement=connection.createStatement(); Submitting the SQL statement --------------------------------- =>Statement object has 2 methods. 1)executeUpdate():- used to submit DML (INSERT,UPDATE and DELETE) SQL statements to the DBMS 2)executeQuery():- used to submit DRL(SELECT) SQL statements to the DBMS. Q)Java application to connect to MySQL DBMS //ConnectionApplication.java import java.sql.*;//JDBC API is made available to the JDBC client class ConnectionApplication{ public static void main(String args[]) throws SQLException{ Connection connection=DriverManager.getConnection("jdbc:mysql://localhost:3306","root","ashokit"); System.out.println("Java application connected to MySQL"); connection.close(); } }