Skip to content
Snippets Groups Projects
Commit 0ce0679d authored by Charlie Darques's avatar Charlie Darques
Browse files

ajout méthode : voir tous les messages d'un thread

parent 97bfcc82
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,27 @@ public class ThreadDAO { ...@@ -35,6 +35,27 @@ public class ThreadDAO {
return messages; return messages;
} }
public List<Message> getAllMessagesFromThread(int threadId){
ArrayList<Message> messages = new ArrayList<>();
try{
PreparedStatement ps = this.con.prepareStatement("SELECT msg FROM msg WHERE thread_id=?;");
ps.setInt(1, threadId);
ResultSet rs = ps.executeQuery();
while(rs.next()){
int msgId = rs.getInt(1);
int userIdMsg = rs.getInt(2);
String msg = rs.getString(3);
messages.add(new Message(msgId,userIdMsg,threadId,msg));
}
} catch (SQLException sqle) {
sqle.getStackTrace();
}
return messages;
}
// Créer un thread // Créer un thread
public void createThread(User user, String threadName) throws SQLException { public void createThread(User user, String threadName) throws SQLException {
PreparedStatement ps = this.con.prepareStatement("INSERT INTO thread (userID_thread, threadName) VALUES(?, ?)"); PreparedStatement ps = this.con.prepareStatement("INSERT INTO thread (userID_thread, threadName) VALUES(?, ?)");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment