A brief explanation : how JDBC works?
java, jdbc
Solution
Why DriverManager class is required? what is it?
The `DriverManager` is registry and lookup mechanism. It is responsible for taking the database connection `URL` and finding a suitable driver capable of using it.
The `DriverManager` is used to maintain a single instance of each driver, which reduces the number of resources required and prevents the need for having multiple instances of the same driver running in memory...
For example, the general `URL` for MySQL starts with `jdbc:mysql://`. The `DriverManager` asks each driver if it understands the `URL`, when it finds one, it passes the URL to it to create the actual connection.
What is a Driver in first place? what does it do?
The driver is a contract between your application and the database. It is a means by which it's possible to write standardized code that can be used against multiple databases, which doesn't actually need to know or care how those calls are physically made to the database.
And also while connecting java with MySql, what is the importance of port?
This is a very basic concept of communication between computers. Think of a computer as a block of units. In order to send a letter to this computer, you need an address, this would be the computers IP address. You also need to know the unit you are sending the letter to, this is the port number.
This allows you to talk with not only the computer, but an individual process. Life would be pretty difficult if you could only talk to one process.
and why is username and password required?
This comes down security. It describes not only who can connect to a particular database, but what they can do, like insert, update, delete and create database objects.
Problem
can anyone in simple words explain what exactly the "steps" in implementing a JDBC mean? What is the importance of each step? Why DriverManager class is required? what is it? What is a Driver in first place? what does it do? Basically I want the internal working of JDBC (with respect to MySqL) , and how is it carried out? And also while connecting java with MySql, what is the importance of port? and why is username and password required?