The concept of civil disobedience is somewhat at odds with democratic government, but it can be argued that it is not fully incompatible with it. The tension with democracy is obvious: democracy only works when a community is able to pass laws with the understanding that all will abide by what the majority desires. Thoreau completely rejects the idea that a person should ever compromise or tolerate a policy he or she did not want. While this is feasible in the case of a few individuals, if Thoreau's approach is generalized, then society would fall apart. However, there is still some sense in which civil disobedience is compatible with democracy.
First, Thoreau is not advocating that people simply deny the existence of unjust laws. Thoreau says that protesters will likely have to pay for the consequences for their actions. This will force society to decide whether it is willing to have all its just citizens in jail. And, if it is willing to allow this, then jail is the only place for good persons to be. Thoreau, then, does not recognize the moral authority of unjust laws (and he, therefore, encourages people to violate them), but he does accept their legal authority (and he, thus, accepts that he may be put in jail).
Secondly, while Thoreau's principle is dangerous if universalized, it is much more benign if people are violating only unjust laws. For unjust laws are usually themselves undemocratic. Unjust laws disenfranchise people or don't recognize due process or place unfair burdens on certain segments of the population. It is a paradox of democracy that democratic institutions can produce laws that violate democratic principles. It remains debatable whether this paradox undermines the democratic process as a whole.