title: JDBC update using prepared statement
body: <p>I am trying to update a table using Java JDBC. The method I am using does not throw any errors but the table is not updating. The create table method is below:</p>
  
  <pre><code>public static void Table()
        {
          Connection c = null;
          Statement stmt = null;
          try {
            Class.forName("org.sqlite.JDBC");
            c = DriverManager.getConnection("jdbc:sqlite:WalkerTechCars.db");
            System.out.println("Opened database successfully");
  
            stmt = c.createStatement();
            String sql = "CREATE TABLE IF NOT EXISTS CUSTOMERS2 " +
                         "(PHONE TEXT PRIMARY KEY     NOT NULL," +
                         " SURNAME            TEXT    NOT NULL, " + 
                         " FIRSTNAME          TEXT     NOT NULL, " + 
                         " HOME               TEXT, " + 
                         " ADDRESS            TEXT, " + 
                         " POSTCODE           Text)"; 
            stmt.executeUpdate(sql);
            stmt.close();
            c.close();
          } catch ( Exception e ) {
            System.err.println( e.getClass().getName() + ": " + e.getMessage() );
            System.exit(0);
          }
          System.out.println("Customers2 created successfully");
        }
  </code></pre>
  
  <p>The update method is below:</p>
  
  <pre><code>public static void updateCustomers()
        {
          Connection c = null;
          PreparedStatement pstmt = null;
          try {
            Class.forName("org.sqlite.JDBC");
            c = DriverManager.getConnection("jdbc:sqlite:WalkerTechCars.db");
            c.setAutoCommit(false);
            System.out.println("Opened database successfully");
  
            String query = "UPDATE CUSTOMERS2 set ADDRESS = ? where PHONE = ? ";
            pstmt = c.prepareStatement(query); // create a statement
            pstmt.setString(1, "1"); // set input parameter 1
            pstmt.setString(2, "DOES THIS WORK"); // set input parameter 2
            pstmt.executeUpdate(); // execute update statement
  
            pstmt.close();
            c.close();
          } catch ( Exception e ) {
            System.err.println( e.getClass().getName() + ": " + e.getMessage() );
            System.exit(0);
          }
          System.out.println("Update Completed successfully HELLO");
        }
  </code></pre>
  
  <p>I have tried to find some clear instructions on this but cant find any. I do not really understand JDBC and prepared statement very well</p>