Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",
"system", "9900479852");
Statement stmt =con.createStatement();
ResultSet rs = stmt.executeQuery("select *from registration where emailid='"+str+"' ");
// here im fetching the emailid from data base
while(rs.next()){
emailId = rs.getString("emailId");
mob = rs.getString("mobilenumber");
System.out.println(emailId);
//here we return update query`enter code here`
if(emailId.equals(str)){
stmt.executeQuery("update registration set password='"+s1+"'
where emailId='"+str+" '"); //query is executing but new vales are not updating to the data base
p.println("updated");
}
con.close();
}
データベースにデータを更新しようとしましたが、更新できませんでした.SQLクエリは実行中ですが、データはデータベースに更新されていません。JDBCを使用してデータベースにデータを更新する方法
JPAやJDBCのチュートリアルに従ってください - あなたのコードは、オープンSQLインジェクション攻撃です。また、私は更新用の新しいstmtを作成し、再利用する必要はないと考えています。 –
アップデートを実行するには、 'executeUpdate()'ではなくexecuteQuery()を使用してください –
私はうんざりしています。うまくいきません。 – darshan