// Note: Driver registration is automatic with JDBC 4+ try (Connection conn = DriverManager.getConnection(url, user, password)) System.out.println("Connected to MySQL successfully!"); catch (SQLException e) System.err.println("Connection failed: " + e.getMessage());

– Add to pom.xml :

import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class MySQLTest public static void main(String[] args) String url = "jdbc:mysql://localhost:3306/your_database"; String user = "your_username"; String password = "your_password";

<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.25</version> </dependency> – Add to build.gradle :

GoodTherapy uses cookies to personalize content and ads to provide better services for our users and to analyze our traffic. By continuing to use this site you consent to our cookies.