Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Java

CRUD Operations with JDBC

Perform insert, select, update, and delete with PreparedStatement.

CRUD Operations with JDBC — a practical guide to Java JDBC CRUD with clear examples you can reuse in real projects.

Java Tutorial Series (75/90). Prefer one article? Read the complete Java tutorial.

Short description

Prepared statements prevent SQL injection and improve reuse.

Insert + select

var ps = conn.prepareStatement("INSERT INTO users(name) VALUES (?)");
ps.setString(1, "Asha");
ps.executeUpdate();

var rs = conn.prepareStatement("SELECT id, name FROM users").executeQuery();
while (rs.next()) {
    System.out.println(rs.getInt("id") + " " + rs.getString("name"));
}

Leave a reply

Your email address will not be published. Required fields are marked *