code:
public int getLastGotKill()
{
Connection con = null;
int last_pvp_time = 0;
try
{
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement statement;
statement = con.prepareStatement("select last_got_kill from characters where obj_Id=?");
statement.setInt(1, getObjectId());
ResultSet rset = statement.executeQuery();
while(rset.next())
{
last_pvp_time = rset.getInt("last_got_kill");
_log.info("last pvp time is : " + last_pvp_time);
}
rset.close();
rset = null;
statement.close();
statement = null;
}
catch(Exception e)
{
if(Config.ENABLE_ALL_EXCEPTIONS)
e.printStackTrace();
}
finally
{
CloseUtil.close(con);
con = null;
}
return last_pvp_time;
}
so when i call this function it gets into the while loop inside the try{} but when i try to print the value of the selected column it prints 0 and so it returns 0…
last_got_kill column in characters table is a bigint(20) type
i can see that there is a number in that column ex. 4294967295 which are
But why do i always get 0 back?
you have to get a long instead . as your number exceeds int range.
Integer.MAX_VALUE is 2147483647which is surely less than 4294967295Long.MAX_VALUE however is 9223372036854775807seems to suit your case.should work.