Java 不使用Discord的SQL
因此,我得到一个数据库,我的discord bot正在连接数据库,但当我得到它时,我得到一个错误com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:where子句中的未知列“D1AA852E1A5046CAFBD55E0D28DEA” 这是我的密码Java 不使用Discord的SQL,java,discord,Java,Discord,因此,我得到一个数据库,我的discord bot正在连接数据库,但当我得到它时,我得到一个错误com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:where子句中的未知列“D1AA852E1A5046CAFBD55E0D28DEA” 这是我的密码 int id = SQLUser.getIntFromDatabase("SELECT * FROM Players WHERE UUID = " + uuid.toString() +
int id = SQLUser.getIntFromDatabase("SELECT * FROM Players WHERE UUID = " + uuid.toString() + "", "ID");
if(id==-1) channel.sendMessage("ID is not valid please login to the WidowMC").queue();
else
{
Message messa = new MessageBuilder().append(Utils.getName(uuid) + " Skull").build();
channel.sendFile(Utils.getSkullFile(Utils.getName(uuid)), messa).queue();
channel.sendMessage("ID = " + id);
}
public static void excuteQuery(String query)
{
Connection conn = Core.getConnection();
try
{
Statement statement = conn.createStatement();
statement.executeQuery(query);
} catch (SQLException e)
{
e.printStackTrace();
}
}
您需要在uuid周围添加引号,使其成为文字,否则Mysql会认为您引用的是列
还要非常小心,您的代码容易受到SQL注入的攻击,正确使用可以帮助您删除该漏洞。如“uuid”?还是其他原因?您正在寻找精确匹配,以便可以使用“=”。问题源于错误的语法缺少引号。看看我链接的文档页面中的示例。