File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes delete tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "delete tag" Watch "delete tag" New topic

delete tag

vicneswaran boi

Joined: Sep 06, 2004
Posts: 13
When ever i compile this code i receive the error "no result set".
I do not understand this error>
Thank u for your help
<%@ page import = "java.sql.*" %>
<%@ page import = "java.util.*" %>
<BODY><P><H2>Confirmation of Deletion </H2>
Connection connection = DriverManager.getConnection("jdbc dbc atabase","","");
Statement statement = connection.createStatement();
int id = Integer.parseInt(request.getParameter("Id"));
ResultSet columns = statement.executeQuery("Delete * FROM Member WHERE Pid ="+ id);
while (
int Id = columns.getInt("Pid");
String Name = columns.getString("Name");
String CName = columns.getString("CName");
String D = columns.getString("D");
<INPUT TYPE = "HIDDEN" name="Id" value=<%=id%>>
<TD><INPUT TYPE = Submit VALUE ="Select"></TD></TR>
<% }
columns.close(); statement.close(); connection.close();

Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi Vicneswaran Boi,

Welcome to JavaRanch!

Your first problem here is that you're using executeQuery() for a DELETE statement. Obviously a DELETE doesn't return a ResultSet, hence your error. Look at executeUpdate() instead. You will also probably need to change "DELETE * FROM" to "DELETE FROM" unless the database you're using is non-standard. Note also that you shouldn't be using the JDBC/ODBC bridge or Statement (rather than PreparedStatement) unless you're just playing or have no alternative.

In future posts, please take more care when stating your question. Your problem is when running - you said compiling. Also state your error exactly as you get it. If you surround your code with the UBB [code] and [/code] it will preserve the formatting and make it easier to read for those willing to help you.

vicneswaran boi

Joined: Sep 06, 2004
Posts: 13
Thank you very much for your help and I will bear your advice in mind
vicneswaran boi

Joined: Sep 06, 2004
Posts: 13
I did the execute update but i seem to find this error....

incompatible types
found : int
required: java.sql.ResultSet
ResultSet columns = statement.executeUpdate("Delete FROM Member WHERE Pid ="+ id); ^

Thank you in advance
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
you should read the docs first. the method executeUpdate() will return you an int, not a ResultSet. and i think the error would be:

incompatible Datatype
found: ResultSet
required: int
jQuery in Action, 2nd edition
subject: delete tag