What Is the Java Persistence API (JPA)?
JPA is the Java specification for mapping objects to relational tables. See entities, the EntityManager, JPQL, the jakarta.persistence rename and common performance fixes.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
JPA is the Java specification for mapping objects to relational tables. See entities, the EntityManager, JPQL, the jakarta.persistence rename and common performance fixes.
Learn to control JDBC transactions with auto-commit, commit and rollback, savepoints, isolation levels and batching, with safe try-with-resources code.
Connection pooling reuses open database connections instead of creating one per request. See how it works and how to set up HikariCP in Java and Spring Boot.
PreparedStatement binds values to placeholders and blocks SQL injection, while Statement runs concatenated SQL. See examples, a comparison table and batching.
Run SELECT and INSERT queries with JDBC using PreparedStatement and try-with-resources, and learn why concatenated SQL is unsafe.
JDBC is the standard Java API for connecting to relational databases. See how drivers, connections, prepared statements, transactions and pooling fit together.
Learn how to look up JNDI resources such as a DataSource with InitialContext, declare them in the server, inject them, and avoid common errors.
JNDI gives Java one API to look up named resources and search directories like LDAP. See DataSource and LDAP examples and how to avoid JNDI injection.
Use try for risky code, catch for specific failures and try-with-resources for closeable objects. Learn exactly when finally runs and what to avoid.
In Java, throw raises an exception inside a method body, while throws declares checked exceptions in the signature. Learn how they work together with examples.
Extend Exception or RuntimeException, add message and cause constructors and carry useful fields. Covers checked vs unchecked, chaining and hierarchies.
Exception chaining wraps a caught exception as the cause of a new one so context is added without losing the original error. See examples and best practices.
AutoCloseable lets try-with-resources release files, connections and executors automatically. See the contract, suppressed exceptions and AutoCloseable versus Closeable.
Try-with-resources closes AutoCloseable resources automatically, even when exceptions occur. See syntax, closing order, suppressed exceptions and best practices.
Try-with-resources closes files, streams and database connections automatically, in reverse order, and keeps the original exception when close() fails too.
Benchmark sequential and parallel streams with JMH instead of manual timers. Learn what decides the speedup and how to confirm it under real load.
A parallel stream runs stream operations on multiple threads using the common ForkJoinPool. Learn how it works, when it helps, and the pitfalls to avoid.
Call stream() on any Collection to get a sequential stream, then filter, map and collect. Includes other sources, parallel conversion and common mistakes.
A Collection stores elements, a Stream processes them lazily in a single-use pipeline. See the differences, examples with toList and groupingBy, and when to choose each.
Use DateTimeFormatter with the parse method of LocalDate, LocalDateTime or ZonedDateTime to turn text into dates, with examples for patterns, locales, strict mode and errors.