SteamWar/SpigotCore
Archiviert
13
0

Storing replays in the database #108

Manuell gemergt
Lixfel hat 4 Commits von fight-replays nach master 2021-08-21 20:05:04 +02:00 zusammengeführt
Nur Änderungen aus Commit 77766621f8 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.sql;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -60,16 +59,13 @@ public class Fight {
}
}
public static OutputStream setReplay(int fightID) {
ResultSet rs = SQL.select("SELECT Replay FROM Fight WHERE FightID = ?", fightID);
public static void setReplay(int fightID, byte[] data) {
Blob blob = SQL.blob();
try {
rs.next();
Blob replay = rs.getBlob("Replay");
if(replay == null)
throw new SecurityException("Replay null");
return replay.setBinaryStream(1);
blob.setBytes(1, data);
} catch (SQLException e) {
throw new SecurityException(e);
}
SQL.update("UPDATE Fight SET Replay = ? WHERE FightID = ?", blob, fightID);
}
}