Sunday 27 October 2024

Detailed explanation of JDBC Programming Model.


Advanced Java: 03

Q.1 Explain about JDBC Programming Model?
a. Requesting for connection or log in to the database server:
  • Java program and database server are communicating with each other is like client server architecture.
  • It's a client duty request for connection.
  • Java program being a client should get connected to the database server.
  • In two ways java program gets connected to database server.
  1. Driver Manager: (without connection pooling)
  2. Datasource: (With Connection pooling)
Q.2 How java program gets connection to the database server?
  • Java program makes use of Driver-Manager or DataSource.
  • By calling getConnection( ) method on Driver Manager or DataSource, JDBC client request for database connection. 
  • Connection connection = DriverManager.getConnection( )
  • getConnection( ) is a library method.
  • It is a static Method.
  • It is used for database connection.
  • java program logged into the database server that logging is called one session.
  • Object oriented representation of JDBC client session with the database server is nothing but connection object.
  • connection is an object. it represents java program session.
  • As long as this session is active (i: e Connection is open) so long java program can perform CRUD operation with the database.
Q.3 How to create Statement Object?

  • By calling createStatement() method on the connection object, statement object is created.
  • Statement statement = connection.createStatement( )
  • createStatement( ) method is a instance method.
  • It is not a static method; it is on the object method.
Q.4 Why to Create Statement Object?
  • Statement object is the designatory object to submit an SQL Statement from a java program to the DBMS.
  • when we want to send a SQL, statement use statement object.
Q.5 How to submit the SQL Statement?
  • java program objective is performing CRUD operation.
  • Without statement we cannot perform CRUD Operation.
  • Statement methods have two methods to submit an SQL Statement to the DBMS.
  1. executeUpdate( String DML)
  2. executeQuery( String DRL)
  • executeUpdate() method is used to submit INSERT, UPDATE & DELETE Statement to the DBMS.
  • executeQuery() method is used to submit SELECT Statement to the DBMS.
Q.6 Why and How to close the statement?
  • by calling close () method on the statement object, statement is closed.
  • statement.close()
  • To release JDBC resources of the JDBC client maintained by the database server, statement should be in closed in JDBC Client.

Q. 7 Why and How to Close the Statement?
  • By calling Close () method on the connection object, connection is closed in the JDBC Client.
  • To release networking resources of the JDBC client maintained by the database server, connection should be closed in JDBC client.

Q.8 What is Database?
  • Database is not MySQL, MongoDB, oracle 
  • Database is a collection of tables of the project.
  • Database = Tables of the project + associated data.
  • database is maintained by database server/DBMS/ RDBMS.

Q.9 How Many Types of DBMS?
  • DBMS are of so many types.
  1. Network based Database Management System.
  2. Object Oriented based DBMS
  3. RDBMS almost used in industry.

data structures and algorithms Web Developer

No comments:

Post a Comment