giozh
giozh

Reputation: 10068

jdbc executeUpdate fail in autocommit mode

in autocommit mode on postgresql database, if jdbc executeUpdate throws SQLException it means that no data on database was modify? or i should set autocommit to false and manage it manually?

Upvotes: 2

Views: 1450

Answers (1)

Juned Ahsan
Juned Ahsan

Reputation: 68715

When a connection is created, it is in autocommit mode. This means that each individual SQL statement is treated as a transaction and is automatically committed right after it is executed. This is true for all JDBC drivers, including the PostgreSQL's one. To start a new transaction, we turn the autocommit off.

To read more and for sample code, check: http://zetcode.com/db/postgresqljavatutorial/

Upvotes: 1

Related Questions