Bonjour,
Je voudrais afficher des données d'une base Mysql mais je rencontre un problème d'accès à MySQL sous easyPHP.
mon objet connection me renvoie la valeur nulle pourtant mon serveur a bien démarré.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.sql.*;
 
public class ConnexionDB {
	private static Connection connection;
 
	static {
		try {
			Class.forName("com.mysql.jdbc.Driver");
 
			String url = "jdbc:mysql://localhost:3306/gestionproduit";
			String user = "root";
			String pass = "";
 
			connection = DriverManager.getConnection(url, user, pass);
		}
		catch(SQLException | ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
 
	public static Connection getConnection() {
		System.out.println(connection);
		return connection;
	}
 
}
Nom : Capture d’écran 2023-09-21 à 14.34.43.png
Affichages : 409
Taille : 137,7 Ko