If you are interacting with the database from a Java application but not using database connection pool libraries, then, you are missing something.
Since creating database connections at runtime takes time and makes request processing slower, it’s always advised to use DB connection libraries. Some of the popular ones are Commons Pool and DBCP.
In a web application, its web server generally provides these functionalities, but in core Java applications, you need to include these connection pool libraries into your classpath to use the database connection pool.
If you want to learn more about JDBC and the connection pool in a web application, I suggest you take a look at the JSP, Servlets, and JDBC for Beginners: Build a Database App course by Chad Darby on Udemy.