how to prevent sql injection i am using below code to login
con = DriverManager.getConnection("", "", "");
Statement statement = con.createStatement();
ResultSet rs= statement.executeQuery("SELECT email,pass FROM db_pass where email='" + email + "'and pass='" + password + "'" );
if (rs.next()) {
String a=rs.getString(1);
String b=rs.getString(2);
rs.close();
it's work fine but when it put (nitin' OR '1'='1) the user is get access without putting valid password