Public static void main(String args) throws SQLException Output Connection established: the registerDriver() method − The registerDriver() method of the DriverManager class accepts an object of the diver class as a parameter and, registers it with the JDBC driver manager. Here, we are trying to register the MySQL driver using the forName() method. Class.forName("") Exampleįollowing JDBC program establishes connection with MySQL database. Using Class.forName() method − The forName() method of the class named Class accepts a class name as a String parameter and loads it into the memory, Soon the is loaded into the memory it gets registered automatically. You can register a database driver in two ways − ![]() To connect with a database using JDBC you need to select get the driver for the respective database and register the driver.
0 Comments
Leave a Reply. |