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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -