Re: How to make getText() return the result in case sensitive ?
On Sep 30, 1:22 pm, Tom Anderson <t...@urchin.earth.li> wrote:
On Mon, 29 Sep 2008, Lew wrote:
Tom Anderson wrote:
On Mon, 29 Sep 2008, tobleron wrote:
Hi, I have an SQL statement like this :
"SELECT * FROM user WHERE userid = '"+ UserIDTxt.getText() +"' AND
passwd = '"+ PasswdTxt.getText() +"'"
Firstly, don't do that. Use a PreparedStatement. It's cleaner, more
efficient, and most importantly, protects against SQL injection attack=
s and
bugs. You should basically never be constructing an SQL string in an a=
pp,
unless you have a very good reason indeed.
Second-most importantly. Most importantly it provides type safety.
Type safety is a wonderful thing, but it's not a prerequisite for
correctness. Protection against SQL injection is.
Let me put it this way - would you rather have an incorrect or unsecure
application written in java, or a correct and secure one written in
python, smalltalk, or javascript?
Neither. It's a false question. The real question is how much effort
it is to create a secure, correct application in either environment.
PreparedStatement is not requisite for protection again SQL
injection. One can protect against those attacks with regular SQL
strings and (unPrepared) Statements. It is the type safety of
PreparedStatement that makes that protection easy and automatic. So
your question should be, "If PreparedStatement weren't type-safe, how
would it be able to protect against SQL injection in the first place?"
--
Lew