This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes quoting in queries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "quoting in queries" Watch "quoting in queries" New topic
Author

quoting in queries

mary bate
Greenhorn

Joined: Jul 30, 2004
Posts: 12
hi guys...juz a simple qn...is jsp case sensitive?

and

String queryText = "insert into sshl values(\"" + request.getParameter("employee_name") + "\");";


String queryText = "insert into sshl values('" + request.getParameter("employee_name")";"

which one is right and wrong? or is both acceptable
[ August 04, 2004: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Yes, JSP, like Java, is case-sensitive.

And since your other question is not a JSP question, I'm moving it to the JDBC forum (with an appropriate change of title).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
There's a syntax error in your second example, so that one's wrong.

To answer your real question, I would always use single quotes when writing SQL queries as not all RDBMS support double quotes. I'm not sure what the ANSI standard says about it.

From a JDBC perspective I'm not sure if it matters as I believe the query string will be processed by the JDBC Driver implementation before being passed on the database in a compatible format. I suppose the degree of processing that takes place would depend on the driver.

Anyway, hope that answers your question.

Jules
mary bate
Greenhorn

Joined: Jul 30, 2004
Posts: 12
ok thanks
 
Don't get me started about those stupid light bulbs.
 
subject: quoting in queries
 
Similar Threads
help needed
IllegalStateException when inserting session attribute into a table
is this statement correct?
simple form registration
invalid character constant