Answers for "how to prevent sql injection in java"

SQL
0

how to prevent sql injection in java

// This should REALLY be validated too
String custname = request.getParameter("customerName");
// Perform input validation to detect attacks
String query = "SELECT account_balance FROM user_data WHERE user_name = ? ";
PreparedStatement pstmt = connection.prepareStatement( query );
pstmt.setString( 1, custname);
ResultSet results = pstmt.executeQuery( );
Posted by: Guest on April-12-2021
0

How to prevent sql Injection

// use prepared statement to prevent SQL injection
$preparedStatement = $dbConnection->prepare('SELECT * FROM animals WHERE name = ?');
$preparedStatement->bind_param('s', $name); 
$preparedStatement->execute();
$result = $preparedStatement->get_result();
while ($row = $result->fetch_assoc()) {
// Process $row
}
Posted by: Guest on July-07-2021

Code answers related to "how to prevent sql injection in java"

Code answers related to "SQL"

Browse Popular Code Answers by Language