我正在用Java编程,我希望替换值不是?
而是:name
,就像PHP的PDO一样。例:
PHP:
$sql = "Insert Into User (name, age) values (:name, :age);";
$insert = $conn->Prepare($sql);
$insert->bindValue(":name", "Pedro");
$insert->bindValue(":age", 21);
$insert->execute();
编辑01
Java(当前):
PreparedStatement select = conn.prepareStatement("Insert Into User (name, age) values (?, ?);");
select.setString(1, "Pedro");
select.setInt(2, 21);
Java(我想要的):
PreparedStatement select = conn.prepareStatement("Insert Into User (name, age) values (:name, :age);");
select.setString(":name", "Pedro");
select.setInt(":age", 21);