Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL query with parameters

843854Feb 12 2002 — edited Feb 12 2002
Hey,
I'm trying to read some information from database with SQL Query. How I can put the parameter that I get from previous *.jsp page to SQL query?
Technologies that I use are WML, JSP and MySQL.
I can get the parameter by method getParameter() and it is correct.
But how to but the requested parameter into sql query and complete the sql query?
Should I read it to some variable before putting it to sql query?

*/ this works fine */
out.println("<p>periodi"+request.getParameter("periodi"+"loppu</p>");

/* this doesn't work */
ResultSet tulokset = lause.executeQuery("select * from kurssi where periodi='+request.getParameter("periodi")+'");

/* this doesn't work */
String periodi=request.getParameter("periodi");
ResultSet tulokset = lause.executeQuery("select * from kurssi where periodi='periodi' '");


Thanks,
Rampe
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 12 2002
Added on Feb 12 2002
3 comments
138 views