Storing replays in the database #108
@ -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);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren