title: ExecuteUpdate sql statement in Java not working
body: <p>I am learning how to use SQL with Java. I have installed the JDBC driver successfully and I am able to read the records from a database and print it on the screen.</p>
  
  <p>My problem occurs when trying to do either an update or insert statement, where nothing happens. Here is my code:</p>
  
  <p><strong>Method where the problem resides</strong></p>
  
  <pre><code>public static void updateSchools(ArrayList&lt;String&gt; newSchool)
  {
      try
      {
          openDatabase();
          stmt = c.createStatement();
          int numberOfRows = stmt.executeUpdate("UPDATE schools SET address='abc' WHERE abbreviation='2';");
          System.out.println(numberOfRows);
          closeDatabase();
      }
      catch (Exception e)
      {
          System.err.println(e.getClass().getName() + ": " + e.getMessage());
          System.exit(0);
      }
  }
  </code></pre>
  
  <p><strong>Support functions</strong></p>
  
  <pre><code>public static void openDatabase()
  {
      c = null;
      stmt = null;
      try
      {
          Class.forName("org.postgresql.Driver");
          c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Badminton", "postgres", "postgrespass");
          c.setAutoCommit(false);
      }
      catch (Exception e)
      {
          System.err.println(e.getClass().getName() + ": " + e.getMessage());
          System.exit(0);
      }
      System.out.println("Database opened successfully");
  }
  
  public static void closeDatabase()
  {
      try
      {
          stmt.close();
          c.close();
      }
      catch (Exception e)
      {
          System.err.println(e.getClass().getName() + ": " + e.getMessage());
          System.exit(0);
      }
      System.out.println("Database closed successfully");
  }
  </code></pre>
  
  <p>Here is an image of my very simple database:
  <a href="https://i.stack.imgur.com/ZF7Rr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZF7Rr.png" alt="enter image description here"></a></p>
  
  <p>The result in the console is the following, although no databases changes were done:</p>
  
  <p>Database opened successfully</p>
  
  <p>1</p>
  
  <p>Database closed successfully</p>
  
  <p>Thanks in advance!</p>