Solved

URGENT!!!-Sql statement

Posted on 2003-12-11
5
245 Views
Last Modified: 2010-04-01
i need to have a sql statement like thiw:

String Query = "delete FROM userskills where username='"+vol.getUsername()+"' "and skill='"+request.getParameter("id")+"'";
  but i get error, i think the way i right sql statement not so ok.

thanks
0
Comment
Question by:Jasbir21
  • 4
5 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 9919920
String Query = "delete FROM userskills where username='"+vol.getUsername()+"' and skill='"+request.getParameter("id")+"'";
0
 
LVL 35

Accepted Solution

by:
TimYates earned 65 total points
ID: 9919939
better is:

PreparedStatement stmt = conn.prepareStatement( "delete FROM userskills where username=? and skill=?" ) ;
stmt.setString( 1, vol.getUsername() ) ;
stmt.setString( 2, request.getParameter( "id" ) ) ;
stmt.executeUpdate() ;

(don't forget to close your statement)

This way, you can't have problems with "SQL injection"

0
 
LVL 35

Expert Comment

by:TimYates
ID: 9919945
0
 

Author Comment

by:Jasbir21
ID: 9919993
thank you very much.

0
 
LVL 35

Expert Comment

by:TimYates
ID: 9920036
:-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now