Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Java WAMP Server

  1. #1
    Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    46
    My Mood
    Cheeky
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Java WAMP Server

    public void deleteBook(int temp)
        {
        	try
            {
                query = "DELETE FROM ccItems WHERE ISBN = '"+temp+"'";
     
                stmt.executeUpdate(query);
     
                JOptionPane.showMessageDialog(null, "Item Deleted !");
            }      
     
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(null, "Error: Could not find ISBN or Already deleted.");
            }
        }

    I have a deleteBook() method where it would delete items in my database. It works properly meaning deleting the specified item with the corresponding ISBN entered. Problem is, if the user inputs an ISBN which IS NOT IN MY DATABASE the try statement still executes. I think the catch statement must execute because the entered ISBN is not found in database.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Java WAMP Server

    Add a call to the printStackTrace() method in the catch block to get the full text of any error messages.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    46
    My Mood
    Cheeky
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Java WAMP Server

    Quote Originally Posted by Norm View Post
    Add a call to the printStackTrace() method in the catch block to get the full text of any error messages.
    Hey, I tried your suggestion there is even no exception being caught by the catch block. The try block does not throw any exception even if the ISBN entered was not found on my database.

Similar Threads

  1. Java on server?
    By TKL in forum Web Frameworks
    Replies: 0
    Last Post: February 2nd, 2013, 11:17 AM
  2. Receive Server Sent Event Notifications in JAVA SERVER PAGE (JSP)
    By amritasenthilkumar in forum Web Frameworks
    Replies: 1
    Last Post: August 17th, 2012, 02:30 PM
  3. Java Application Server
    By goutamdaphtari in forum Java Theory & Questions
    Replies: 0
    Last Post: July 14th, 2010, 11:53 PM
  4. Replies: 2
    Last Post: July 7th, 2009, 02:34 PM
  5. Replies: 10
    Last Post: May 8th, 2009, 10:49 AM