我正在尝试在 Java 应用程序中执行 PrepardStatmenet,但是出现错误。我传递的值是正确的。
UPDATE characters SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, exp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, demonMarking = ?, map = ?, meso = ?, hpApUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, pets = ?, subcategory = ?, marriageId = ?, currentrep = ?, totalrep = ?, gachexp = ?, fatigue = ?, charm = ?, charisma = ?, craft = ?, insight = ?, sense = ?, will = ?, honourExp = ?, honourLevel = ?, damage = ?, showdamage = ?, totalwins = ?, totallosses = ?, pvpExp = ?, pvpPoints = ?, reborns = ?, apstorage = ?, name = ?, school = ? WHERE id = ?
出于某种原因,它给了我:
You have an error inyour SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'WHERE id = 1' at line 1
忽略“?”。这是因为我在 Java 应用程序中使用了准备语句。
这是整个代码:
ps = con.prepareStatement("UPDATE characters SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, exp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, demonMarking = ?, map = ?, meso = ?, hpApUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, pets = ?, subcategory = ?, marriageId = ?, currentrep = ?, totalrep = ?, gachexp = ?, fatigue = ?, charm = ?, charisma = ?, craft = ?, insight = ?, sense = ?, will = ?, honourExp = ?, honourLevel = ?, damage = ?, showdamage = ?, totalwins = ?, totallosses = ?, pvpExp = ?, pvpPoints = ?, reborns = ?, apstorage = ?, name = ?, school = ? WHERE id = ?", 1);
ps.setInt(1, this.level);
ps.setInt(2, this.fame);
ps.setInt(3, this.stats.getStr());
ps.setInt(4, this.stats.getDex());
ps.setInt(5, this.stats.getLuk());
ps.setInt(6, this.stats.getInt());
ps.setLong(7, ((this.level >= 250) || ((GameConstants.isKOC(this.job)) && (this.level >= 250))) && (!isIntern()) ? 0L : this.exp);
ps.setInt(8, this.stats.getHp() < 1 ? 50 : this.stats.getHp());
ps.setInt(9, this.stats.getMp());
ps.setInt(10, this.stats.getMaxHp());
ps.setInt(11, this.stats.getMaxMp());
StringBuilder sps = new StringBuilder();
for (int i = 0; i < this.remainingSp.length; i++) {
sps.append(this.remainingSp[i]);
sps.append(",");
}
String sp = sps.toString();
ps.setString(12, sp.substring(0, sp.length() - 1));
ps.setInt(13, this.remainingAp);
ps.setByte(14, this.gmLevel);
ps.setByte(15, this.skinColor);
ps.setByte(16, this.gender);
ps.setInt(17, this.job);
ps.setInt(18, this.hair);
ps.setInt(19, this.face);
ps.setInt(20, this.demonMarking);
if ((!fromcs) && (this.map != null)) {
if ((this.map.getForcedReturnId() != 999999999) && (this.map.getForcedReturnMap() != null))
ps.setInt(21, this.map.getForcedReturnId());
else
ps.setInt(21, this.stats.getHp() < 1 ? this.map.getReturnMapId() : this.map.getId());
}
else {
ps.setInt(21, this.mapid);
}
ps.setLong(22, this.meso);
ps.setShort(23, this.hpApUsed);
if (this.map == null) {
ps.setByte(24, (byte)0);
} else {
MaplePortal closest = this.map.findClosestSpawnpoint(getTruePosition());
ps.setByte(24, (byte)(closest != null ? closest.getId() : 0));
}
ps.setInt(25, this.party == null ? -1 : this.party.getId());
ps.setShort(26, (short)this.buddylist.getCapacity());
StringBuilder petz = new StringBuilder();
int petLength = 0;
for (MaplePet pet : this.pets) {
if (pet.getSummoned()) {
pet.saveToDb();
petz.append(pet.getInventoryPosition());
petz.append(",");
petLength++;
}
}
while (petLength < 3) {
petz.append("-1,");
petLength++;
}
String petstring = petz.toString();
ps.setString(27, petstring.substring(0, petstring.length() - 1));
ps.setByte(28, this.subcategory);
ps.setInt(29, this.marriageId);
ps.setInt(30, this.currentrep);
ps.setInt(31, this.totalrep);
ps.setInt(32, this.gachexp);
ps.setShort(33, this.fatigue);
ps.setInt(34, ((MapleTrait)this.traits.get(MapleTrait.MapleTraitType.charm)).getTotalExp());
ps.setInt(35, ((MapleTrait)this.traits.get(MapleTrait.MapleTraitType.charisma)).getTotalExp());
ps.setInt(36, ((MapleTrait)this.traits.get(MapleTrait.MapleTraitType.craft)).getTotalExp());
ps.setInt(37, ((MapleTrait)this.traits.get(MapleTrait.MapleTraitType.insight)).getTotalExp());
ps.setInt(38, ((MapleTrait)this.traits.get(MapleTrait.MapleTraitType.sense)).getTotalExp());
ps.setInt(39, ((MapleTrait)this.traits.get(MapleTrait.MapleTraitType.will)).getTotalExp());
ps.setInt(40, getHonourExp());
ps.setInt(41, getHonourLevel());
ps.setLong(42, this.damage);
ps.setInt(43, this.showdamage);
ps.setInt(44, this.totalWins);
ps.setInt(45, this.totalLosses);
ps.setInt(46, this.pvpExp);
ps.setInt(47, this.pvpPoints);
ps.setInt(48, this.reborns);
ps.setInt(49, this.apstorage);
ps.setString(50, this.name);
StringBuilder spss = new StringBuilder();
for (int i = 0; i < this.school.length; i++) {
spss.append(this.school[i]);
spss.append(",");
}
String spss00 = spss.toString();
ps.setString(51, spss00.substring(0, spss00.length() - 1));
ps.setInt(52, this.id);