Try this:
private static void addOfflineItem(int owner_id, int item_id, int count)
{
try(Connection con = L2DatabaseFactory.getInstance().getConnection())
{
PreparedStatement st = con.prepareStatement("SELECT count FROM items WHERE item_id=? AND owner_id=?");
st.setInt(1, item_id);
st.setInt(2, owner_id);
ResultSet rs = st.executeQuery();
if(rs.next())
{
st = con.prepareStatement("UPDATE items SET count=? WHERE owner_id=? and item_id=?");
st.setInt(1, rs.getInt("count") + count);
st.setInt(2, owner_id);
st.setInt(3, item_id);
}
else
{
st = con.prepareStatement("INSERT INTO items VALUES (?, ?, ?, ?, 0, 'INVENTORY', 0, 0, 0, NULL, 0, 0, -1)");
st.setInt(1, owner_id);
st.setInt(2, IdFactory.getInstance().getNextId())
st.setInt(3, item_id);
st.setInt(4, count);
}
st.execute();
rs.close();
st.close();
}
catch (SQLException e)
{
_log.severe("Could not update item char: " + e);
}
}
I changed the Long for Int (because that's your input on the function), also your "objectId" generation method was wrong.
Remember to import net.sf.l2j.gameserver.idfactory.IdFactory;