MySQL JDBC Driver Connection String



The MySQL JDBC connection string look like this −

Class.forName("com.mysql.jdbc.Driver");

Above, Driver is an interface.

Whenever your JDBC is running outside an application server, then the class DriverManager establish the connection. The DriverManager class is as follows −

conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/yourdatabaseName","yourRootName","yourPassword");

Now, I am applying the above connection string to connect Java to MySQL database. The code is as follows.

connection string

The following is the output that shows that MySQL connection with Java is successful.

connection successful
Updated on: 2019-07-30T22:30:23+05:30

426 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements