データベースにレコードを追加しようとしています。私はこの機能で間違いを見つけることができません。誰でも助けることができますか?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());
}
}
メイン
でinsertTable(4 , "test" , "test" , "test" , 1 , "test" , 4);
これはPrtScをテーブルです:
疑問符の最初のグループに対して疑問符の代わりに列名を指定する必要があります –
「INSERT INTO employee(?、?、?、?、?、?、?)」から '?'ここで '? 'の代わりに列名を追加する必要があります。 –