Самые популярные вопросы и ответы для интервью и онлайн-тесты
Образовательная платформа для подготовки к интервью, онлайн-тестов, учебных материалов и живой практики

Развивайте навыки с целевыми маршрутами обучения, пробными тестами и контентом для подготовки к интервью.

WithoutBook объединяет вопросы для интервью по предметам, онлайн-практику, учебные материалы и сравнительные руководства в одном удобном учебном пространстве.

Chapter 5

Executing CRUD: INSERT, SELECT, UPDATE, DELETE with JDBC

Learn how Java code performs basic database operations using JDBC with clear examples and practical guidance.

Inside this chapter

  1. INSERT Example
  2. SELECT Example
  3. UPDATE and DELETE
  4. Why CRUD Still Matters

Series navigation

Study the chapters in order for the clearest path from beginner JDBC concepts to advanced data-access design and production usage. Use the navigation at the bottom of each page to move through the full series.

Tutorial Home

Chapter 5

INSERT Example

String sql = "INSERT INTO students(name, email) VALUES(?, ?)";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
    ps.setString(1, "Riya Sen");
    ps.setString(2, "riya@example.com");
    int rows = ps.executeUpdate();
}
Chapter 5

SELECT Example

String sql = "SELECT id, name, email FROM students";
try (PreparedStatement ps = connection.prepareStatement(sql);
     ResultSet rs = ps.executeQuery()) {
    while (rs.next()) {
        System.out.println(rs.getInt("id") + " " + rs.getString("name"));
    }
}
Chapter 5

UPDATE and DELETE

String updateSql = "UPDATE students SET name = ? WHERE id = ?";
String deleteSql = "DELETE FROM students WHERE id = ?";

These operations typically use executeUpdate(), which returns the number of affected rows.

Chapter 5

Why CRUD Still Matters

Even though JDBC has advanced features, most business applications still rely heavily on good CRUD handling. Learning these patterns well builds confidence for every later topic.

Авторские права © 2026, WithoutBook.