Results 1 to 1 of 1
  1. #1
    sevendaysky is offline Member
    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0

    Default Modifying code to permit update/delete/query by ID

    Okay. Class project, netbeans connecting to mySQL database. After clarifying some issues with mentor, mentor pointed out that for the update/delete/query actions, asking what type of student (graduate, etc) is not required; just ID. So... I need to figure out how to modify my code to ask for student ID (for the delete/update sections) and then ... the mentor said it should be query all or query by ID. I'm having a really bad brain day and can't figure out how to modify the code to make it work. Here's an example snippet.

    Note that the program works at this point, and will add, update, query, and delete... just has to be modified to fit the "new" criteria. This is in the class meant to "drive" the whole deal. The individual groups(graduate, part time, etc) have their own little delete snippets in each class that are simple "delete FROM * WHERE studentID" sorts of things.
    Java Code:
    private void queryStudent() {
            System.out.print("Choose the type:\n1- Undergraduate, 2- Graduate, 3- Part-Time: ");
            int type = 0;
            Student st;
            do {
                while (!scan.hasNextInt()) {
                    scan.next();
                }
                type = scan.nextInt();
                scan.nextLine();
            } while (type < 0 || type > 3);
            if (type == 1) {
                st = new Undergraduate();
            } else if (type == 2) {
                st = new Graduate();
            } else {
                st = new PartTime();
            }
            st.query();
        }
    Last edited by JosAH; 06-08-2013 at 09:00 AM. Reason: added [code] ... [/code] tags

Similar Threads

  1. how to delete, update rows in AbstractTableModel
    By stefan_banu in forum AWT / Swing
    Replies: 4
    Last Post: 05-26-2013, 01:25 AM
  2. self-modifying code
    By gyijhbk in forum New To Java
    Replies: 1
    Last Post: 06-27-2012, 08:42 AM
  3. Modifying Given Code
    By jmscarlet9 in forum New To Java
    Replies: 5
    Last Post: 04-01-2012, 06:13 PM
  4. Modifying Automato Code
    By whateverme in forum New To Java
    Replies: 0
    Last Post: 02-06-2011, 03:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •