jijesh
jijesh

Reputation: 35

update not working in JDBC

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

Answers (1)

Pau Carre
Pau Carre

Reputation: 471

You should either finish the transaction:

conn.commit();

or set the atutocommit before creating the prepared statements:

conn.setAutoCommit(true);

Upvotes: 1

Related Questions