title: JDBC and Oracle conn.commit and conn.setAutocommit not working properly
body: <p>I have made a DBManager class as shown below</p>
  
  <pre><code>public class DBManager {
  
  
        public static String DRIVER = "oracle.jdbc.driver.OracleDriver";
        public static String URL = "jdbc:oracle:thin:@//localhost:1521/DB";
        public static String USERNAME = "afsweb";
        public static String PASSWORD = "afsweb";
        public static String DOCDBUSERNAME = "docdb";
        public static String DOCDBPASSWORD = "docdb";
        public static int PORT = 1521;
  
      //static Logger log = Logger.getLogger(ExcelDBManager.class.getName());
      public static Connection getConnection(String url ,String username, String password){
      try {
          Class.forName(DRIVER);
      } catch (ClassNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      Connection con = null;
      try {
          con = DriverManager.getConnection(url,username,password);
          con.setAutoCommit(false);
          } catch (SQLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
  
      }
      return con;
  }
  </code></pre>
  
  <p>And i have method truncate rows in table</p>
  
  <pre><code>public static void truncate() throws SQLException{
          conn = DBManager.getConnection(DBManager.URL, DBManager.USERNAME, DBManager.PASSWORD);
          System.out.println(conn.getAutoCommit()  +"");
          Statement pstmnt = null;
          ResultSet rs = null;
          try{    
              pstmnt = conn.createStatement();
              pstmnt.executeQuery("truncate table bd_vehicles_temp_1");
              System.out.println("Query Executed");
          }
          catch(SQLException e){
              e.printStackTrace();
          }
          finally{
              try{
              if(rs !=null){
                  rs.close();
              }
              if(pstmnt != null){
                  pstmnt.close();
              }
              if(conn != null){
                  conn.close();
              }
              }
              catch(SQLException e)
              {
                  e.printStackTrace();
              }
          }
      }
  </code></pre>
  
  <p>Now i have not written conn.commit inside my truncate() method. Also i have setAutocommit to false. Even then the changes are reflected in database.</p>
  
  <p>On Executing the above method i get output as </p>
  
  <pre><code>false
  Query Executed
  </code></pre>
  
  <p>Which means my connections autocommit mode is false. Still the changes made by truncate method is reflected in database. What could be the possible reason  ?? I am using Oracle Database.</p>
  
  <p>Thanks in Advance !</p>