It is advisable to soak most dried beans or legumes overnight before cooking.
Replace the soaking water with two to three cups of fresh water for each cup of beans when cooking them. Most beans require about one and a half to two hours of cooking to become soft. Lentils and split peas require only one hour and need not be soaked prior to cooking.
Make sure the beans are thoroughly cooked, as they are more difficult to digest when undercooked. Always keep in mind that it is important to chew them thoroughly. As you get into the habit of eating more beans regularly, you will digest them better. Your good bacteria in your digestive track will need to get conditioned to digesting increased amounts of beans. Any discomfort will eventually go away.