This equation is solvable iff the greatest common divisor of a and b is 1, i.e., a and b are coprime. The numbers x and y can be found using the extended Euclidean algorithm (look at other sections of the article as well). The bottom of the article has a link to an applet that solves the equation. Another applet is found on cut-the-knot site. For an efficient way to solve the equation see this post.