statement = con.prepareStatement("SELECT * FROM accounts WHERE login = ?");
statement.setString(1, newacc);
rs = statement.executeQuery();
if(!rs.next())
{
sendPacket(new MoveCharToAccResponse(player, 1));
return;
}
}
catch(Exception e)
{
log.warning("Can't recive password for account " + oldacc + ", exciption :" + e);
}
finally
{
DatabaseUtils.closeDatabaseSR(statement, rs);
}
//Encode old password and compare it to sended one, send packet to determine changed or not.
try
{
if(!LoginController.DEFAULT_CRYPT.compare(pass, dbPassword))
{
sendPacket(new MoveCharToAccResponse(player, 0));
}
else
{
statement = con.prepareStatement("UPDATE accounts SET login = ? WHERE login = ?");
statement.setString(1, newacc);
statement.setString(2, oldacc);
int result = statement.executeUpdate();
L2LoginClient client = LoginController.getInstance().getAuthedClient(oldacc);
if(result != 0)
{
Log.add("<old=\"" + oldacc + "\" new=\"" + newacc + "\" ip=\"" + (client != null ? client.getIpAddress() : "0.0.0.0") + "\" />", "accounts");
}
sendPacket(new MoveCharToAccResponse(player, 2));
}
}
catch(Exception e1)
{
e1.printStackTrace();