These prepositions always take accusative case (den, das, die, die):
durch
für
gegen
ohne
um
They are easy to remember because they can be sung to the tune of raindrops keep falling on my head.
These prepositions always take dative case (dem, dem, der, den).
aus
außer
bei
mit
nach
seit
von
zu
They are easy to remember because they can be sung to the tune of blue danube.
These prepositions take accusative or dative case.
If you remember the prepositions above, you don't have to remember these (if they are not on one of the previous lists, they are probably on this list). However, these prepositions can be sung to the tune of ode to joy.
an
auf
hinter
in
neben
über
unter
vor
zwischen
The prepositions govern accusative case if the prepositional phrase modifies a verb of motion:
Die Katze läuft unter den Tisch.
The prepositions govern dative case if the prepositonal phrase modifies a stationary verb:
Die Katze schläft unter dem Tisch.
When the motion vs. stationary is irrelevant, the prepositions usually take accusative (e.g. denken an + acc; sich freuen auf)
Finally, there is a small group of prepositions tht takes the genitive case (des, des, der, der)
(in many German dialects, in some dialects they take the dative case, but that won't work as an excuse on a test!)
(an)statt (instead of)
trotz (in spite of)
während (during)
wegen (because of)