Maybe you are too occupied with thought of failing.
Rather than doing that focus on your present and do the best you can .
Set daily study targets for yourself.
You need to make a schedule and stick to it. If you prepare well and are confident, you'll pass with flying colours :)
Hey. I also had the same problem when I was younger. But then you realize that you study because you're decided to study (and because you're interested in the topic) and that already going so far shows that you're capable of a lot of things. And be honest, if you fail something once, it is not the end of the world. You can still restudy for the test and do it again. I am not saying to not study at all, I am just saying, that one bad grade is not the end of the world.
In your case I would do it like this. I would go to the teacher and tell him that you're anxious and if he can help you with what you need to focus on (usually teachers like when you show them interest in their work/topic), tell your parents//oommates that you have anxiety with this as well and find a group to study with them. I remember there was always a group who did study for test together. Breathe. Do some meditation. And as already people write here, make a schedule. But a realistic one. Don't study 4 hours in a row. Do 45 min in the morning, go for a walk, come back, do another 45 min and so on. It is important that you make some breaks inbetween and that you turn off the mobilephone and other exuipment in the time of studing for exam. Do some nice things as well. I always treated myself with some nice chocholate or tea after the studing. Good luck!