Posts

Showing posts with the label DriverManager

How to Establish a Database Connection in Java Using JDBC (DriverManager Explained)

Establishing a Database Connection in JDBC (Java) To communicate with a database server from a Java application, the programmer must establish a database connection using JDBC (Java Database Connectivity). Role of DriverManager and Connection The DriverManager class is present in the java.sql package. It provides static factory methods to create and return an object of the Connection interface. The Connection interface represents an active connection between a Java program and a database server. 👉 The implementation of the Connection interface is provided by the database vendor (such as MySQL, Oracle, PostgreSQL) inside a JDBC driver JAR file (e.g., mysql-connector.jar). JDBC API vs JDBC Driver              Component.                                   Description java.sql package.                 Part of JDBC API (avai...