Automatically switching from 9V battery to DC wall adapter on insertion
All you need is 2 diodes for your 2 power sources. Your circuit will use power from the one with the highest voltage.







simulate this circuit &ndash; Schematic created using CircuitLab

When the adapter is plugged in, V1 will be 11 volts (ish). When the adapter is removed, your circuit will have 8 volts at V1 from the battery. There is no risk of the battery being charged by the adapter as the battery diode will block all current in the reverse direction.

The diode part numbers are not critical. Just select diodes that match the current needed by your circuit.