Java is compatible with all database like Oracle ,SQL ,MYSQl and many more it is just the way the connection object is to be created.
The API for different Database differ so you have to download a specific API jar like classs12.jar for Oracle and keep the jar in the class path