Reputation: 35
Hi I have created an application for inventory management.
But when I do the update function, the flow was OK and no errors are found at runtime. But the table remains unchanged.
conn = getConnection();
preStmt = conn
.prepareStatement("UPDATE category SET name=? where id=?;");
preStmt.setString(1, category.getCategoryName());
preStmt.setInt(2, category.getCategoryId());
preStmt.executeUpdate();
closeDb();
Upvotes: 0
Views: 334
Reputation: 471
You should either finish the transaction:
conn.commit();
or set the atutocommit before creating the prepared statements:
conn.setAutoCommit(true);
Upvotes: 1