Я пытаюсь добавить запись в базу данных. Я не могу найти ошибку в этой функции. любой может помочь?java msql вставить запись в таблицу
public static void insertTable(int idEmployee , String First_Name , String Last_Name , String Password , int Sex , String Mail , int Employee_idEmployee) throws Exception {
Connection conn = (Connection) getConnection() ;
try {
PreparedStatement insertStatement = (PreparedStatement) conn.prepareStatement("INSERT INTO employee (?,?,?,?,?,?,?) VALUES (?,?,?,?,?,?,?)");
insertStatement.setInt(1, idEmployee);
insertStatement.setString(2, First_Name);
insertStatement.setString(3, Last_Name);
insertStatement.setString(4, Password);
insertStatement.setInt(5, Sex);
insertStatement.setString(6, Mail);
insertStatement.setInt(7 ,Employee_idEmployee);
insertStatement.close();
conn.close() ;
System.out.println("it's ok");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
и Main
insertTable(4 , "test" , "test" , "test" , 1 , "test" , 4);
это PRTSC стол:
Вы должны указать имена столбцов вместо вопросительных знаков для первой группы вопросительных знаков –
либо вам придется удалить '?' Из 'INSERT INTO employee (?,?,?,?,?,?,?)' здесь или вам нужно будет добавить имена столбцов вместо '?'. –