Computing.Net > Forums > Programming > java sql

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

java sql

Reply to Message Icon

Name: noel
Date: November 11, 2002 at 03:45:06 Pacific
OS: 98
CPU/Ram: 32
Comment:

I'm using java as my prog. language
I have problem delete a row in the database
This is my sql statement. Whats wrong with it?It deletes all entry in the field rather than only the row i wanted it to be.

String query = "DELETE FROM Students" +
"' WHERE id=" + fields.name.getText();
output.append( "\nSending query: " +
connection.nativeSQL( query ) + "\n" );

I have tried another method which i can delete only the row i specify inside the bracket .absolute(3) /delete row 3 in database.Following is the code:

Statement statement = connection.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

ResultSet uprs = statement.executeQuery( "SELECT ID, emailaddress FROM Employee");
uprs.absolute(3);
uprs.deleteRow();
uprs.refreshRow();


What is the correct way to write the codes so that I can delete the row where "login = "'+login'" ".


Thank you.
-Noel-



Sponsored Link
Ads by Google

Response Number 1
Name: moog
Date: November 12, 2002 at 04:21:54 Pacific
Reply:

I'm not a good SQL programmer but I seem to notice something unusual in your query statement.
You typed in : String query = ... "'WHERE id=" + ...

maybe you forgot the single closing qoute around the WHERE:
String query = ... "'WHERE' id =" + ...

Your query statement as it is might evaluate to :
String query = "DELETE * FROM Students + ...



0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: java sql

Java sql server procedure problem www.computing.net/answers/programming/java-sql-server-procedure-problem/11989.html

SQL / Oracle / Java Problem with results www.computing.net/answers/programming/sql-oracle-java-problem-with-results/2315.html

Java and SQL Server 7.0 www.computing.net/answers/programming/java-and-sql-server-70/10976.html