0

I have this code

public void insertStart_auto_load_test_step_info(int countUsers ) throws SQLException{      
    String insert_auto_load_test_user_info = "insert into auto_load_test_step_info(id_user_info,start_time,step_id) values(" + getIdValue1()+ getCrokStarTime() +  "2";
    PreparedStatement pstmt = this.con.prepareStatement(insert_auto_load_test_user_info, Statement.RETURN_GENERATED_KEYS);
    pstmt.executeUpdate();

And this Class

public class Info {
    private int crok = 0; 
    private int testId = 0; 
    private int testCaseId = 1; 
    private long starTime; 
    private long crokStarTime; 
    private long crokFinishTime; 
    int [] idValue1 = new int[100];
    int [] idValue2 = new int[100];
    int id_case_info = 0;


    public int[] getIdValue2() {
        return idValue2;
    }
    public void setIdValue2(int idValue2, int i) {
        this.idValue2[i] = idValue2;
    }
    public int getId_case_info() {
        return id_case_info;
    }
    public void setId_case_info(int id_case_info) {
        this.id_case_info = id_case_info;
    }
    public int[] getIdValue1() {
        return idValue1;
    }
    public void setIdValue1(int idValue1, int i) {
        this.idValue1[i] = idValue1;
}

I need add to my Insert value from this method getIdValue1(), how can I do that? I think, there must be some sort of index, but I don't know how to use it.

Robert
  • 7,394
  • 40
  • 45
  • 64
  • Btw.: Please check https://stackoverflow.com/questions/419021/how-does-javas-preparedstatement-work on how to use prepared statements correctly by using place holders. – Progman Dec 04 '19 at 18:08

1 Answers1

0

Model it after your setIdValue2() method.

// You should check, somewhere, that i is a valid index of idValue2
public int getIdValue2(int i) {
  return idValue2[i];
}

And now, you may call your method: int temp = getIdValue2(0); // Get item at first index

sleepToken
  • 1,866
  • 1
  • 14
  • 23