L298 DC Motor control

Hi, I looked if this question was already on the forum and I didn't find it, If there is please get me the link and I'll remove this thread.
Now about the problem, I have an Arduino UNO connected to a display(This part is working) and a L298(not the shield, just that).
The L298(motor driver) is then connected to a 9v battery(Battery ground connected to Arduino ground and +9V connected to the supply pin of the driver) and a DC motor connected between Out1 and Out2. Whenever I attach the motor to the output pin it goes on for about 2 seconds, then the computer says that the arduino disconnected(several times) and the display acts like if the arduino resetted but the motor keeps spinning. I know that this should happen if the current gets too high, but I don't really see what the problem could be. Removing the motor, the program goes on without problems and if I put a LED and a resistor instead everything goes fine, where the problem could be?(I am using the same configuration of a tutorial I've found online and I kinda understood how the L298 works).

No! Those puny 9V batteries cannot power motors, never designed for that current level.

You need a good quality pack of AA's or a mains supply which can source enough
current for your motor(s).

The reason the Arduino disconnects is that the motor drags the 9V supply down to 4.3V
in a couple of seconds, at which point protection diodes in the L298 start conducting and
drain motor power from the 5V Arduino rail. This should NOT be happening, its likely to
damage the L298 (and possibly your USB controller on the computer).

People are strongly advised to power Arduinos from powered USB hubs rather than
direct from the computer when working with circuits with voltage supplies above 5V.

That way if something goes wrong you only risk destroying a USB hub, not a laptop
or desktop computer.

Well I didn't know that it could be so dangerous, I'll pay more attention by now. An indipendent generator that is attached to my house's electrical supply would do better(as the supply voltage for the motor)?

You know how much current the motor takes? What is it nominal voltage and whats
the resistance across the terminals when stationary? Divide V/R to give the stall
current.