How to avoid overloading due to code duplication?

How to avoid overloading due to code duplication?

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.

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.

InsertMethods

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());
}

}


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners

Java Essentials : Learn Core Java From Basic to Advance

Learn Java Programming Using Practical Assignments. Start Building Back-end Web Applications Robust Test Automation Frameworks By End Of The Course. Learn More!

Fundamentos de Java: Aprende Java desde cero, sin misterios | Simpliv

Fundamentos de Java: Aprende Java desde cero, sin misterios