{"id":1188,"date":"2022-08-30T15:13:51","date_gmt":"2022-08-30T15:13:51","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/how-to-give-entry-in-the-where-clause-when-we-use-it-in-webpages-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:13:51","modified_gmt":"2022-08-30T15:13:51","slug":"how-to-give-entry-in-the-where-clause-when-we-use-it-in-webpages-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-to-give-entry-in-the-where-clause-when-we-use-it-in-webpages-collection-of-common-programming-errors\/","title":{"rendered":"How to give entry in the where clause when we use it in webpages?-Collection of common programming errors"},"content":{"rendered":"<p>In contrast to other responses, why not use a PreparedStatement?<\/p>\n<p>Basically, you&#8217;ll have to code like this:<\/p>\n<pre><code>PreparedStatement st=conn.prepareStatement(\"select * from empdetails where empnum=?\");\nst.setString(1, jempId);\nResultSet rs=st.executeQuery();\n<\/code><\/pre>\n<p>The reason you should use PreparedStatements is because of SQL Injection issues. For example, using the code you posted in the question, a hacker can always type &#8220;1;delete * from empdetails&#8221; in the textbox from which you select jempid.<\/p>\n<p>Thus the final query formed would be<\/p>\n<pre><code>select * from empdetails where empnum=1;delete * from empdetails\n<\/code><\/pre>\n<p>which would result in all data in empdetails getting deleted.<\/p>\n<p>So always use PreparedStatements!!<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:38:25. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>In contrast to other responses, why not use a PreparedStatement? Basically, you&#8217;ll have to code like this: PreparedStatement st=conn.prepareStatement(&#8220;select * from empdetails where empnum=?&#8221;); st.setString(1, jempId); ResultSet rs=st.executeQuery(); The reason you should use PreparedStatements is because of SQL Injection issues. For example, using the code you posted in the question, a hacker can always type [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1188","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1188"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1188\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}