Actually to work with a database schema, you need to make a connection with it. After that, you can query any database entities such as tables, views, stored procedures, ... which are associated to that schema.
Without using any connection pool (which is very common in Java projects) you can use some code like this:
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/javabase";
String username = "java";
String password = "password";
System.out.println("Connecting database...");
try (Connection connection = DriverManager.getConnection(url, username, password)) {
System.out.println("Database connected!");
//execute any query
} catch (SQLException e) {
throw new IllegalStateException("Cannot connect the database!", e);
}
However, I suggest using a connection pool which is more practical. You can also refer to this thread which provides you some detail information.
Connect Java to a MySQL database