LinusHuck
Explore posts from serversJCHJava Community | Help. Code. Learn.
•Created by LinusHuck on 5/10/2024 in #java-help
Problems with sql
Mariadb
The Best thing is that it only accous like 1 out of 20 times
@Override
public ArrayList<String> getMessages(UUID partyUUID, int lastMessageID)
{
String sql = "SELECT message FROM PartyChat WHERE partyUUID = ? AND id > ?";
ArrayList<String> messages = new ArrayList<>();
try(Connection conn = partyDatabase.getConnection(); PreparedStatement stmt = conn.prepareStatement(sql))
{
stmt.setString(1, partyUUID.toString());
stmt.setInt(2, lastMessageID);
try(ResultSet resultSet = stmt.executeQuery())
{
while(resultSet.next())
{
messages.add(resultSet.getString("message"));
}
}
}
catch(SQLException e)
{
e.printStackTrace();
Logger.info(CoreModule.getPlugin(), "MySQLDatabase", "There was a problem while getting the messages!");
}
return messages;
}
@Override
public ArrayList<String> getMessages(UUID partyUUID, int lastMessageID)
{
String sql = "SELECT message FROM PartyChat WHERE partyUUID = ? AND id > ?";
ArrayList<String> messages = new ArrayList<>();
try(Connection conn = partyDatabase.getConnection(); PreparedStatement stmt = conn.prepareStatement(sql))
{
stmt.setString(1, partyUUID.toString());
stmt.setInt(2, lastMessageID);
try(ResultSet resultSet = stmt.executeQuery())
{
while(resultSet.next())
{
messages.add(resultSet.getString("message"));
}
}
}
catch(SQLException e)
{
e.printStackTrace();
Logger.info(CoreModule.getPlugin(), "MySQLDatabase", "There was a problem while getting the messages!");
}
return messages;
}
45 replies