我使用此命令插入一个新客户端,我在 Java 中有一个方法,我将值分配给命令:
insertNewPerson = connection.prepareStatement(
"INSERT INTO Addresses " +
"(FirstName, LastName, Email, PhoneNumber, ClientAddress ) " +
"VALUES (?, ?, ?, ?, ?)" );
问题:我正在寻找类似的东西,但要删除程序文本字段中的任何条目。
这是我用来在 sql 命令中设置值的 Java 方法:
public int addPerson(
String fname, String lname, String email, String num, String caddress)
{
int result = 0;
//set parameters, then execute insertNewPerson
try {
insertNewPerson.setString(1, fname);
insertNewPerson.setString(2, lname);
insertNewPerson.setString(3, email);
insertNewPerson.setString(4, num);
insertNewPerson.setString(5, caddress);
//insert the new entry; return # of rows updated
result = insertNewPerson.executeUpdate();
}//end try
catch(SQLException sqlException) {
sqlException.printStackTrace();
close();
}//end catch
return result;
}//end method addPerson