Firstly, your saved variable is stored in the global namespace, that is common to all addons. If any other addon also names its saved variable "AddonDB", you are in trouble.
Then, the saved variable is not available until the ADDON_LOADED event is fired with your addon. If you are testing the variable in the main chunk, it is normally not loaded.
You should do something like this to catch your variables :
-- Fetch the addon name
local addonName = ...
-- Create an anonymous frame
local eventFrame = CreateFrame("Frame")
-- Register the ADDON_LOADED event
-- Set the event callback
eventFrame:SetScript('OnEvent', function(self, event, arg1)
-- Test if this is the ADDON_LOADED event for this addon
if event == 'ADDON_LOADED' and arg1 == addonName then
-- Unregister the event, as we do not need it anymore
-- Initialize the saved variables
-- ... (do your stuff there)
By the way, I suggest you to use some library like AceDB-3.0 to handle your saved variables as it can automatically handle default values (and could later handle profiles if you would like it to do so).