title: How to avoid overloading due to code duplication?
body: <p>I am trying to insert the name,hashed password,salt and the hash type to the database. Only thing changing is the type of the parameters. I believe that it can be done more efficiently. How can I avoid using overloading? Do I need to use generics? Thank you.</p>
  
  <p><strong>InsertMethods</strong></p>
  
  <pre><code>protected void insert(String name, String secretpassword, String salt, String type)
  {
      String sql = "INSERT INTO login(username,password,salt,type) VALUES(?,?,?,?)";
  
      try (Connection conn = this.connect();
           PreparedStatement pstmt = conn.prepareStatement(sql)) {
          pstmt.setString(1, name);
          pstmt.setString(2, secretpassword);
          pstmt.setString(3, salt);
          pstmt.setString(4, type);
          pstmt.executeUpdate();
          System.out.println("Successful");
      } catch (SQLException e) {
          System.out.println(e.getMessage());
      }
  }
  
  protected void insert(String name, byte[] secretpassword, String salt, String type)
  {
      String sql = "INSERT INTO login(username,password,salt,type) VALUES(?,?,?,?)";
  
      try (Connection conn = this.connect();
           PreparedStatement pstmt = conn.prepareStatement(sql)) {
          pstmt.setString(1, name);
          pstmt.setString(2, Arrays.toString(secretpassword));
          pstmt.setString(3, salt);
          pstmt.setString(4, type);
          pstmt.executeUpdate();
          System.out.println("Successful");
      } catch (SQLException e) {
          System.out.println(e.getMessage());
      }
  }
  </code></pre>