Correctifs du commit précédent

This commit is contained in:
2015-05-11 04:44:35 +02:00
parent dddaa83fe0
commit 10afd18f35
7 changed files with 115 additions and 11 deletions

View File

@@ -62,7 +62,7 @@ public class MPMessageTable extends SQLTable<MPMessageElement> {
public List<MPMessageElement> getAllUnreadForPlayer(String player) throws SQLException {
if (!AbstractCommandExecutor.isValidPlayerName(player)) return null;
return getAll("viewerNick = "+player+" AND read = 0", "time ASC", null, null);
return getAll("viewerNick = '"+player+"' AND wasRead = 0", "time ASC", null, null);
}

View File

@@ -2,6 +2,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
@@ -87,9 +88,16 @@ public abstract class SQLElement {
st.setString(i+1, values[i]);
}
id = st.executeUpdate();
st.close();
st.executeUpdate();
ResultSet rs = st.getGeneratedKeys();
if(rs.next())
{
id = rs.getInt(1);
}
saved = true;
st.close();
}
} catch (SQLException e) {
e.printStackTrace();