how to prevent SQL-injectie java code example
Example 1: how to prevent sql injection in java
String custname = request.getParameter("customerName");
String query = "SELECT account_balance FROM user_data WHERE user_name = ? ";
PreparedStatement pstmt = connection.prepareStatement( query );
pstmt.setString( 1, custname);
ResultSet results = pstmt.executeQuery( );
Example 2: how to prevent sql injection in java
public List<AccountDTO> unsafeFindAccountsByCustomerId(String customerId) throws SQLException {