Occupied by both French and Russian troops during the Napoleonic wars , it became a sovereign state in 1806 and joined the Germanic Confederation in 1815 .