Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How does building an sql query in java using query builder help prevent sql injection?

user-image
Question added by Zeeshan Mohammad , Software Engineer in Research , Center for Collective Intelligence - Massachusetts Institute of Technology
Date Posted: 2013/10/02
Bilal Hassan
by Bilal Hassan , Principal Software Engineer | Full Stack Developer , TEO International & IE, Islamabad

Because Query Builder defines parameterised queries so that it verify the input string by the user. And do not let the user to enter malicious data in input parameter.

 

Note: Parametering of input variables in query is the v basic level of stoping SQL injections. to proper blocking Please use Store Procedures.

MOHAMED MAHMOUD EISSA
by MOHAMED MAHMOUD EISSA , Software department MGR. and Senior developer , Global Media Services GMS

SQL allows expressions in almost every clause and position the Doctrine 

QueryBuilder can only prevent SQL injections for calls to the methods setFirstResult() and setMaxResults().

 

All other methods cannot distinguish between user- and developer input and are therefore subject to the possibility of SQL injection.

 

To safely work with the QueryBuilder you should NEVER pass user input to any of the methods of the QueryBuilder and use the placeholder ? or :name syntax in combination with $queryBuilder->setParameter($placeholder, $value) instead:

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.