2016-09-23 2 views

答えて

1

あなたが$aを持ってa変数の値を使用する場合は、プリペアドステートメントを使用して、それを埋めるために必要があります。

String a = request.getParameter("from"); 
PreparedStatement ps = connection.prepareStatement(// Create a prepared statement 
    "select * from flight where f = ?"    // Using ? for where the 
);             // parameter goes 
ps.setString(1, a);         // Fill in the value (they 
                // start a 1, oddly) 
ResultSet resultset = ps.executeQuery();   // Execute the query 

文字列であっても、?の周りには引用符を入れないことに注意してください。 PreparedStatementは、DBドライバレベルであなたのために、SQL injectionから安全な方法で処理します。

関連する問題