Most likely explanation is that they acquired Sun for their hardware line to directly compete against system integrators like HP. MySQL, Java, etc. just came as part of the package.
Fact is that Oracle bought Sun to have control of Java. As many know, all the middleware and development tools that Oracle sells for its database are written in Java. They even tried to replace with some success Pro*C with some sort of Java from hell in the late 90's.