Bonjour,
Je développe un projet similaire a Youtube. Serveur de difusions a la demande.
J'utilise Debian 8.8 et 9.3, avec pour base de données Mysql 5.7, Tomcat 9.0.2 et eclipse oxygen, dans mon projet je fait appel au design pattern DAO.
Je tourne en ronds depuis quelques jours sur une méthode qui n"est pas vu par la classe parente.
J'utilise plusieurs classes dont DaoFactory.java (qui fournit la connection a la base) et VideoDaoImpl.java (qui est l'implémentation de mes méthodes).

Voici mon code DaoFactory.java
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.classrooms.dao;
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
 
import java.util.Properties;
 
public class DaoFactory {
    private String url;
    private String username;
    private String password;
    private static String       protocol    = "jdbc:mysql://localhost:3306/";
    private static String       driver      = "org.gjt.mm.mysql.Driver";
 
 
    DaoFactory(String url, String username, String password) {
        this.url = url;
        this.username = username;
        this.password = password;
    }
 
    public static DaoFactory getInstance() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
 
        }
 
        DaoFactory instance = new DaoFactory(
        		"jdbc:mysql://localhost:3306/videoee?useSSL=false", "root", "toto");
        return instance;
    }
 
 
    // Récupération du Dao
    public VideoDao getVideoDao() {
        return new VideoDaoImpl(this);
    }
 
 
     // cette méthode n"est pas vue par la classe videoDaoImpl.java
    public Connection getConnection( String dbName, String user, String password )
    throws ClassNotFoundException, SQLException
    {
        Properties      props = new Properties(); // connection properties
        props.put( "root", user );
        props.put( "toto", password );
        props.put( "useSSL", "false" ); // for MySQL 5.7 - shuts up SSL verification warning
 
        Class.forName( driver );
 
        return DriverManager.getConnection( protocol + dbName );
    }
 
 
}
VideoDaoImpl.java
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.classrooms.dao;
 
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
 
import com.classrooms.beans.BeanException;
import com.classrooms.beans.Video;
import com.classrooms.dao.*;
 
public class VideoDaoImpl implements VideoDao {
    private DaoFactory daoFactory;
 
    VideoDaoImpl(DaoFactory daoFactory) {
        this.daoFactory = daoFactory;
    }
 
    @Override
    public void ajouter(Video video) throws DaoException {
        Connection connexion = null;
        PreparedStatement preparedStatement = null;
 
        try {
            connexion = daoFactory.getConnection(); // erreur sur getConnection
            preparedStatement = connexion.prepareStatement("INSERT INTO video(fichier, titre, commentaire) VALUES(?, ?, ?, ?);");
            preparedStatement.setString(1, video.getFichier());
            preparedStatement.setString(3, video.getTitre());
            preparedStatement.setString(4, video.getCommentaire());
            preparedStatement.executeUpdate();
            connexion.commit();
        } catch (SQLException e) {
            try {
                if (connexion != null) {
                    connexion.rollback();
                }
            } catch (SQLException e2) {
            }
            throw new DaoException("Impossible de communiquer avec la base de données SQLException");
        }
        finally {
            try {
                if (connexion != null) {
                    connexion.close();  
                }
            } catch (SQLException e) {
                throw new DaoException("Impossible de communiquer avec la base de données SQLException");
            }
        }
 
    }
 
    @Override
    public List<Video> lister() throws DaoException {
        List<Video> videos = new ArrayList<Video>();
        Connection connexion = null;
        Statement statement = null;
        ResultSet resultat = null;
 
        try {
 
        	connexion = DaoFactory.getConnection(); // erreur sur getConnction
            statement = connexion.createStatement();
            resultat = statement.executeQuery("SELECT fichier, titre, commentaire FROM video;");
 
            while (resultat.next()) {
 
            	String fichier = resultat.getString("fichier");
                String titre = resultat.getString("titre");
                String commentaire = resultat.getString("commentaire");
 
                Video video = new Video();
                video.setFichier(fichier);
                video.setTitre(titre);
                video.setCommentaire(commentaire);
 
                videos.add(video);
            }
        } catch (SQLException e) {
            throw new DaoException("Impossible de communiquer avec la base de données; SQLException");
        } catch (BeanException e) {
            throw new DaoException("Les données de la base sont invalides: bean");
        }
        finally {
            try {
                if (connexion != null) {
                    connexion.close();  
                }
            } catch (SQLException e) {
                throw new DaoException("Impossible de communiquer avec la base de données : fermeture");
            }
        }
        return videos;
    }
 
}
Je ne comprends pas d'ou vient mon erreur car dans les imports je déclare les programmes.

Salutations
Philippe