how to delete entry in a database through java servlet run in eclipse??


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: how to delete entry in a database through java servlet run in eclipse??

  1. #1
    Join Date
    Dec 2007
    Posts
    1

    how to delete entry in a database through java servlet run in eclipse??

    Hello , I need help editing this java code which aims to delete an entry from a database run by mysql. this code will be run through eclipse. I already tried to edit and made sure all variable names and types were correct but it just would not work. Please help! thanks a lot!!!


    public String delResolution(int id)
    {
    try
    {
    ConMan con = new ConMan();
    Statement stmt = con.logOn().createStatement();
    String msg = "";
    String sql = "delete from ledger where id="+id;
    if (stmt.execute(sql))
    {
    msg = "Delete failed";
    } else
    {
    msg = "Delete successfully";
    }
    con.logOff();
    return msg;

    }
    catch (SQLException e)
    {
    return "Delete. SQL error " + e.getMessage();
    }
    catch (java.lang.NullPointerException ne)
    {
    return "<p>Null error: " + ne.getMessage();
    }

    }
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Welcome to DevX

    Does it return an error or just not work?

    (Also, please do not post duplicate threads in different sections for the same question. Thanks. )
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Database not properly created
    By Arjuna in forum Database
    Replies: 2
    Last Post: 07-25-2007, 04:22 AM
  2. Replies: 7
    Last Post: 10-18-2005, 12:51 AM
  3. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 07:46 AM
  4. .NET vs. Enterprise Java: Who's Got Better Security?
    By Glen Kunene in forum Talk to the Editors
    Replies: 17
    Last Post: 03-23-2002, 01:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center