Database access is an important part of many Java applications and thankfully Java comes with JDBC (Java Database Connectivity) API Which provides a standard set of APIs for connecting to any relational database.
As an application developer, you just need to know the API as all vendors provide an implementation of those APIs. You just need to include their JAR file into the classpath and your code will work fine.
By the way, JDBC is not the only option to interact with the database, there are open source libraries like JOOQ which can help you to write SQL queries in Java.
jOOQ generates Java code from your database and lets you build type-safe SQL queries through its fluent API