title: VACUUM cannot run inside a transaction block
body: <p>My application has this code:</p>
  
  <pre><code>Connection connection = DriverManager.getConnection(url, userName, password);
  connection.setAutoCommit(false);
  try {
      Statement statement = connection.createStatement();
      try {
          statement.executeUpdate("TRUNCATE mytable");
      } finally {
          statement.close();
      }
      connection.commit();
      connection.setAutoCommit(true);
      statement = connection.createStatement();
      try {
          statement.executeUpdate("VACUUM mytable");
      } finally {
          statement.close();
      }
      connection.setAutoCommit(false);
      connection.commit();
  } finally {
      connection.close();
  }
  </code></pre>
  
  <p>It fails on <code>statement.executeUpdate("VACUUM mytable");</code> because <code>VACUUM cannot run inside a transaction block</code>.</p>
  
  <p>I must be missing some notions as I thought that setting the autocommit to <code>true</code> would remove the transaction context (needed for <code>TRUNCATE</code>). Apparently it doesn't. So how do I get out of the transactional context and perform my VACUUM successfully? How should I write my code to not have this transactional context?</p>