
JDBC Tutorial How to Connect to a Database Step by Step
Connect to PostgreSQL with JDBC, run queries and updates with prepared statements, read results safely and manage transactions, in one runnable example.
Tag
6 posts

Connect to PostgreSQL with JDBC, run queries and updates with prepared statements, read results safely and manage transactions, in one runnable example.

Stop SQL injection in Java by binding values with parameters in JDBC, JPA and Spring, allow-listing identifiers and limiting what the database account can do.

Why HikariCP reports that a connection is not available, how to tell a leak from a pool that is too small, and how to size the pool for the database.

Fix the PostgreSQL JDBC connection refused error by checking that the server runs and listens, the host and port are right, and Docker networking is correct.

Fix No suitable driver found by checking the driver jar is on the runtime classpath, the URL prefix is right and the registration survived packaging.

Read integrity violation errors for MySQL and PostgreSQL, tell unique, foreign key and not-null failures apart and handle them without losing the real bug.