postgresql - VACUUM cannot run inside a transaction block -


my application has code:

connection connection = drivermanager.getconnection(url, username, password); connection.setautocommit(false); try {     statement statement = connection.createstatement();     try {         statement.executeupdate("truncate mytable");     } {         statement.close();     }     connection.commit();     connection.setautocommit(true);     statement = connection.createstatement();     try {         statement.executeupdate("vacuum mytable");     } {         statement.close();     }     connection.setautocommit(false);     connection.commit(); } {     connection.close(); } 

it fails on statement.executeupdate("vacuum mytable"); because vacuum cannot run inside transaction block.

i must missing notions thought setting autocommit true remove transaction context (needed truncate). apparently doesn't. how out of transactional context , perform vacuum successfully? how should write code not have transactional context?


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -