• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

delete tag

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When ever i compile this code i receive the error "no result set".
I do not understand this error>
Thank u for your help
<HTML>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.util.*" %>
<HEAD>
</HEAD>
<BODY><P><H2>Confirmation of Deletion </H2>
<TABLE BORDER=1 WIDTH="700" CELLPADDING=3 CELLSPACING=1>
<TR>
<TD>ID</TD>
<TD>Committee_Name</TD>
<TD>Commitee_Full</TD>
<TD>Description</TD></TR>
<FORM ACTION="Delete8.jsp" METHOD="POST">
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
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 (columns.next())
{
int Id = columns.getInt("Pid");
String Name = columns.getString("Name");
String CName = columns.getString("CName");
String D = columns.getString("D");
%>
<TR>
<TD><%=Id%></TD>
<TD><%=Name%></TD>
<TD><%=CName%></TD>
<TD><%=D%></TD>
<INPUT TYPE = "HIDDEN" name="Id" value=<%=id%>>
<TD><INPUT TYPE = Submit VALUE ="Select"></TD></TR>
</FORM>
<% }
columns.close(); statement.close(); connection.close();
%>

</FORM>
</TABLE>
</BODY>
</HTML>
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Jules
 
vicneswaran boi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for your help and I will bear your advice in mind
 
vicneswaran boi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic