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 16 of 16

Thread: Aggravating project, need fresh eyes and help

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Aggravating project, need fresh eyes and help

    I'm in a Java programming course in college. For some reason, for a noncertified course, they want us to do this big project that includes building a student records management... thing. I think I have it ... mostly... done. Except the one class that's meant to drive the whole thing is driving me up the wall. There are a number of issues, but... yes. I need someone to take a look and help me figure out how to fix the problem so it will at least work.
    private void updateStudent() {
        System.out.print("Choose the type:\n1=Undergraduate 2=Graduate 3=PartTime: ");
            int type = 0;
            StudentRecords 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();
            }
            System.out.print("Enter the stduentID: ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            int id = scan.nextInt();
            scan.nextLine();
            st.setStudentID(id);
            readStudent(st);
            st.update ();
        }

    it's the middle part, where it talks about st = new Undergraduate(); that my Netbeans keeps flagging and not liking. If you want to see the whole project let me know.


  2. #2
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Aggravating project, need fresh eyes and help

    What exactly the error is?

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Hi, in the code snippet above, the if/else sequence where "st = new Undergraduate();" is listed, each one comes up red in Netbeans. Alt-entering gets the following message: "constructor Undergraduate cannot be applied to given types; required: String, String, int, double, String, String, String found: no arguments reason: actual and formal argument lists differ in length" and then alt enter suggests creating constructor Undergraduate() in student.Undergraduate.

    I realize it's a bit complicated. I have the project exported, but don't know where to post it so others could see it.

  4. #4
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Check, what constructors does Undergraduate have and what does not.

  5. #5
    Junior Member
    Join Date
    Jun 2013
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Okay, I fixed the constructor problem, but ran into a new one. My query is not working properly. After speaking to the mentor, she indicated that query should be by ID and/or "query all." This is the bit I have in now:
    --
    Need a little help figuring out how to modify it to ask for only student ID and go from there.
    Last edited by jps; June 7th, 2013 at 06:38 PM. Reason: removed link

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 262 Times in 231 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Please post the code in question on the forum, and not through some link.

  7. #7
    Junior Member
    Join Date
    Jun 2013
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Aggravating project, need fresh eyes and help

    It was a pastebin link... it was the code. But fine... think query is okay now but need to go to delete. It needs to just delete a user-specified student ID rather than asking first for graduate-undergraduate-parttime. I realize this is just a code snippet, but the entire project spans six class files and posting all of them would just be too long... and I can't link to pastebin either so. Just need to figure out how to rewrite it to accept user input of studentid and either delete or update. query by id update maybe too.

    private void deleteStudent() {
            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();
            }
            System.out.print("Please enter the student ID: ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            int id = scan.nextInt();
            scan.nextLine();
            st.setStudentID(id);
            st.delete();
        }

  8. #8
    Member
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    54
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Quote Originally Posted by sevenday View Post
    Just need to figure out how to rewrite it to accept user input of studentid and either delete or update. query by id update maybe too.
    When you refer to updating or deleting content, do you mean that you want the program to write (and later read) from an external file, where each student ID is on a separate line or separated by a delimiter?

    Quote Originally Posted by sevenday View Post
    It needs to just delete a user-specified student ID rather than asking first for graduate-undergraduate-parttime.
    When the user enters 1, 2 or 3, a new object is created. In doing so, I'm guessing a student ID set for each object automatically. If that's the case, then you want the program to delete a student ID right away, however, this can be problematic if you're not writing to an external file and the program has just be ran as there will be no data to delete. Before deleting, you should have some way of checking to make sure there is at least 1 set student ID.

    I'm a bit confused, do you want the program to delete a student ID before asking the user to enter 1, 2 or 3? If so, why not just move that segment of code, or am I misunderstanding what you're asking?

    Also, the last 2 lines of code are a bit unusual, however, it may be due to only seeing a code snippet. Are you setting the student ID to whatever the user entered, then deleting it right away? If so, setting it is an unnecessary step. I may be wrong in this though since I cannot see the code for those methods.

  9. #9
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 262 Times in 231 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Quote Originally Posted by sevenday View Post
    It was a pastebin link... it was the code. But fine...
    We ask that you post all relevant materials on the forum because we have no way to guarantee a third party will continue to host your content for the thread. This way the content is under control of this forum. Thank you for your cooperation.

    If you are having trouble writing code to accept user input, I suggest starting with a small program (like a hello world example) and adapt it to print what the user types instead of "Hello world". Post the code if you have any questions.

  10. #10
    Junior Member
    Join Date
    Jun 2013
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Quote Originally Posted by jps View Post
    a small program (like a hello world example) and adapt it to print what the user types instead of "Hello world".
    That's not the problem for me. I'm just having trouble picking out how to take user input (in this case an integer, studentID) and using that to select a database row and delete it. I know this part: SELECT * FROM student WHERE= .... and there it stops, because I've tried + getstudentID and that doesn't work.

    Regarding the question about external file: Yes, there is an external registrar.sql file that is accessed to add, update, delete, etc. It has to persist. Student ID is not automatically assigned, it is given by the user. When a student is added, the program asks for a student ID. if I type in 55, I need to be able to call up that entry for student ID 55 without needing to ask whether the student is an undergraduate, graduate, or part time (the 1 - 2 - 3 if/else sequence currently existing). The query is working for now. It's the update/delete sections that I'm wrestling with now.

    I realize that the solution is likely very simple and I'm just not seeing it.

    Edit to add: I know that you need to see the whole code to understand it and explain it but if I tried to paste all six class files here it would be a hugely long post. I don't know else to get around that and still adhere to the no-link rule. I'm sorry.

  11. #11
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 262 Times in 231 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Quote Originally Posted by sevenday View Post
    That's not the problem for me. I'm just having trouble picking out how to take user input (in this case an integer, studentID) and using that to select a database row and delete it.
    This describes multiple things. Which one specific thing are you stuck on? Reading input? Selecting a row? Deleting the row? Updating the display?

    Quote Originally Posted by sevenday View Post
    I know this part: SELECT * FROM student WHERE= ....
    I do not understand what that means

    Quote Originally Posted by sevenday View Post
    I've tried + getstudentID and that doesn't work.
    Post the code where you tried that. It is hard to say what might have gone wrong without seeing it.

    Quote Originally Posted by sevenday View Post
    I know that you need to see the whole code to understand
    No, not really.

    Quote Originally Posted by sevenday View Post
    if I tried to paste all six class files here it would be a hugely long post. I don't know else to get around that and still adhere to the no-link rule. I'm sorry.
    This is why I said to adapt a "Hello world" program. They are short and easy to understand. Once you have the concept, you can apply it to your project. See SSCCE.org

  12. #12
    Junior Member
    Join Date
    Jun 2013
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Aggravating project, need fresh eyes and help

    I know how to get user input and add it to a database or print it back out to the user. The problem is how to pick ONE entry out of a database, based on user input, and delete or update it. I need to be able to type in any student ID (that exists) and update or delete it. Edit: Without needing to know what category it's in first! Right now it uses an if/else set to select from categories, but I don't need to do that.

    This is the code for the application driver class.

    package teststudent;
     
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Scanner;
     
    public class StudentApp{
     
        private Scanner scan = new Scanner(System.in);
     
        public static void main(String[] args) {
            new StudentApp().displayMenu();
        }
     
        //Creates SMS menu
        private void displayMenu() {
            System.out.println("Student Management System");
            int menu;
     
            while ((menu = getOption()) != 6) {
                switch (menu) {
                    case 1:
                        addStudent();
                        break;
                    case 2:
                        updateStudent();
                        break;
                    case 3:
                        deleteStudent();
                        break;
                    case 4:
                        queryStudent();
                        break;
                    case 5:
                        calculateTuition();
                        break;
                    default:
                        System.out.println("Please select an option between 1 and 6.");
                        break;
                }
                System.out.print("\nPlease press enter to continue.");
                scan.nextLine();
            }
            System.out.println("\nThank you for using the system.");
        }
     
        private int getOption() {
            System.out.println();
            System.out.println("1. Add Student");
            System.out.println("2. Update Student");
            System.out.println("3. Delete Student");
            System.out.println("4. Query Student");
            System.out.println("5. Calculate Tuition");
            System.out.println("6. Exit");
            System.out.print("Enter your choice (1-6): ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            int opt = scan.nextInt();
            scan.nextLine();
            return opt;
        }
     
        //Adds a student
        private void addStudent() {
            System.out.print("Please enter the student ID: ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            int id = scan.nextInt();
            scan.nextLine();
            System.out.print("Choose the type of student:\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.setStudentID(id);
            st.setStudentID(id);
            readStudent(st);
            st.add();
        }
     
        //Reads student information from user
        private void readStudent(Student st) {
            System.out.print("Please enter student's first name: ");
            st.setFirstName(scan.next());
            scan.nextLine(); // skip
            System.out.print("Please enter student's last name: ");
            st.setLastName(scan.next());
            scan.nextLine();
            System.out.print("Please enter student's GPA: ");
            while (!scan.hasNextDouble()) {
                scan.next();
            }
            st.setGPA(scan.nextDouble());
            scan.nextLine();
            System.out.print("Choose the student's status(1- Resident, 2- Non-Resident): ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            if (scan.nextInt() == 1) {
                st.setStatus("Resident");
            } else {
                st.setStatus("Non-Resident");
            }
            scan.nextLine();
     
            if (st instanceof Graduate) {
                Graduate gst = (Graduate) st;
                System.out.print("Please enter the thesis title: ");
                gst.setThesisTitle(scan.nextLine());
                System.out.print("Please enter the thesis advisor: ");
                gst.setThesisAdvisor(scan.nextLine());
            } else if (st instanceof Undergraduate) {
                Undergraduate ust = (Undergraduate) st;
                System.out.print("Please choose the student's level:\n1- Freshman, 2- Sophomore, 3- Junior, 4- Senior: ");
                int id = 0;
                do {
                    while (!scan.hasNextInt()) {
                        scan.next();
                    }
                    id = scan.nextInt();
                    scan.nextLine();
                } while (id < 0 || id > 4);
                if (id == 1) {
                    ust.setLevel("Freshman");
                } else if (id == 2) {
                    ust.setLevel("Sophomore");
                } else if (id == 3) {
                    ust.setLevel("Junior");
                } else if (id == 4) {
                    ust.setLevel("Senior");
                }
            } else if (st instanceof PartTime) {
                PartTime pst = (PartTime) st;
                System.out.print("Please enter the name of the company: ");
                pst.setCompany(scan.nextLine());
            }
        }
     
        //Update a student record
        private void updateStudent() {
            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();
            }
            System.out.print("Please enter the student ID: ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            int id = scan.nextInt();
            scan.nextLine();
            st.setStudentID(id);
            readStudent(st);
            st.update();
        }
     
        //Deletes a student record
        private void deleteStudent() {
            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();
            }
            System.out.print("Please enter the student ID: ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            int id = scan.nextInt();
            scan.nextLine();
            st.setStudentID(id);
            st.delete();
        }
     
        //Queries for a student record
        private void queryStudent() {
            Connect gc = new Connect();
            Statement stmt = null;
            Connection conn = gc.getSimpleConnection();
            try {
                stmt = conn.createStatement();
                String select = "SELECT * FROM student";
                ResultSet rs = stmt.executeQuery(select);
                System.out.println("Student Records:");
                while (rs.next()) {
                    System.out.println("Student ID#:\t" + rs.getString("studentID"));
                    System.out.println("First Name:\t" + rs.getString("firstName"));
                    System.out.println("Last Name:\t" + rs.getString("lastName"));
                    System.out.println("Grade Average(GPA):\t" + rs.getString("gpa"));
                    System.out.println("Status:\t" + rs.getString("status"));
                    System.out.println("Mentor name:\t" + rs.getString("mentor"));
                    System.out.println("Level:\t" + rs.getString("level"));
                    System.out.println("Thesis title:\t" + rs.getString("thesisTitle"));
                    System.out.println("Thesis advisor:\t" + rs.getString("thesisAdvisor"));
                    System.out.println("Company:\t" + rs.getString("company"));
                    System.out.println("\n");
                }
                stmt.close();
                conn.close();
            } catch (SQLException e) {
                System.out.println(e.getMessage());
            }
        }
     
        //Calcuate's student tuition
        private void calculateTuition() {
            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();
            }
     
            System.out.print("Please enter the student's hours: ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            int hours = scan.nextInt();
            scan.nextLine();
     
            System.out.print("Choose the student's status(1- Resident, 2- Non-Resident): ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            int status = scan.nextInt();
            scan.nextLine();
     
            double value = st.calculateTuition(hours, status);
            System.out.printf("The tuition is %.2f\n", value);
        }
    }

  13. #13
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 262 Times in 231 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Quote Originally Posted by sevenday View Post
    I know how to get user input and add it to a database or print it back out to the user. The problem is how to pick ONE entry out of a database
    Work on this part first.
    How do you get an element from the database to print it to the user? Short of writing the code for you I do not know how to better answer the question.

    --- Update ---

    Perhaps you can describe in more detail what you are having problems with specifically? What line of code do you get to? ...as in the line that searches the database or the line of code that returns the found element

  14. #14
    Junior Member
    Join Date
    Jun 2013
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Aggravating project, need fresh eyes and help

    EDIT: I fixed the delete portion of it. Whew. Still working on the update. Below is revised relevant part of the code; above is the full class to show the parts surrounding the snippet.

    private void updateStudent() {
            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();
            }
            System.out.print("Please enter the student ID: ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            int id = scan.nextInt();
            scan.nextLine();
            st.setStudentID(id);
            readStudent(st);
            st.update();
        }

    At this point I'm working on figuring out how to replace that footer (the st.setStudentID(id); to st.update(); part) with something more functional and coherent, minus the top block up to the second while statement.

    Second Edit: The above block refers to "readStudent" in the abstract class - this is the snippet containing that section.

    private void readStudent(Student st) {
            System.out.print("Please enter student's first name: ");
            st.setFirstName(scan.next());
            scan.nextLine(); // skip
            System.out.print("Please enter student's last name: ");
            st.setLastName(scan.next());
            scan.nextLine();
            System.out.print("Please enter student's GPA: ");
            while (!scan.hasNextDouble()) {
                scan.next();
            }
            st.setGPA(scan.nextDouble());
            scan.nextLine();
            System.out.print("Choose the student's status(1- Resident, 2- Non-Resident): ");
            while (!scan.hasNextInt()) {
                scan.next();
            }
            if (scan.nextInt() == 1) {
                st.setStatus("Resident");
            } else {
                st.setStatus("Non-Resident");
            }
            scan.nextLine();
     
            if (st instanceof Graduate) {
                Graduate gst = (Graduate) st;
                System.out.print("Please enter the thesis title: ");
                gst.setThesisTitle(scan.nextLine());
                System.out.print("Please enter the thesis advisor: ");
                gst.setThesisAdvisor(scan.nextLine());
            } else if (st instanceof Undergraduate) {
                Undergraduate ust = (Undergraduate) st;
                System.out.print("Please choose the student's level:\n1- Freshman, 2- Sophomore, 3- Junior, 4- Senior: ");
                int id = 0;
                do {
                    while (!scan.hasNextInt()) {
                        scan.next();
                    }
                    id = scan.nextInt();
                    scan.nextLine();
                } while (id < 0 || id > 4);
                if (id == 1) {
                    ust.setLevel("Freshman");
                } else if (id == 2) {
                    ust.setLevel("Sophomore");
                } else if (id == 3) {
                    ust.setLevel("Junior");
                } else if (id == 4) {
                    ust.setLevel("Senior");
                }
            } else if (st instanceof PartTime) {
                PartTime pst = (PartTime) st;
                System.out.print("Please enter the name of the company: ");
                pst.setCompany(scan.nextLine());
            }
        }
    Last edited by sevenday; June 8th, 2013 at 04:55 PM. Reason: more info

  15. #15
    Member
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    54
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re: Aggravating project, need fresh eyes and help

    Quote Originally Posted by sevenday View Post
    That's not the problem for me. I'm just having trouble picking out how to take user input (in this case an integer, studentID) and using that to select a database row and delete it. I know this part: SELECT * FROM student WHERE= .... and there it stops, because I've tried + getstudentID and that doesn't work.
    Are there any errors that appear? There are a few problems I see. First, in your statement, you're only specifying a table name but not the database where that table can be found. Instead, try SELECT * FROM databaseName.tableName. Second, try using PreparedStatements when manipulating data in the database as they are better at handling variables. Basically, the Statement is kept to access the database and table, while the prepared statements will do all the hard work.

    Here is a link to the documentation for prepared statements: PreparedStatement (Java Platform SE 6)

    Third, whenever you're writing/reading to external files or a SQL database, you should place the .close() methods in a finally block so it will always be executed no matter if the code will enter the catch. For example:

    try {
    // code that will be run
    } catch (Exception ex) {
    // something that will happen if there is an Exception error
    } finally {
    resultSet.close();
    statement.close();
    connection.close();
    // if you want to be thorough, you can check to see whether each is not null then close.
    }

    Quote Originally Posted by sevenday View Post
    Regarding the question about external file: Yes, there is an external registrar.sql file that is accessed to add, update, delete, etc. It has to persist. Student ID is not automatically assigned, it is given by the user. When a student is added, the program asks for a student ID. if I type in 55, I need to be able to call up that entry for student ID 55 without needing to ask whether the student is an undergraduate, graduate, or part time (the 1 - 2 - 3 if/else sequence currently existing). The query is working for now. It's the update/delete sections that I'm wrestling with now.
    Before figuring out the code for updating, you need to make the resultSet updatable because by default, they are not. Happily, the Java documentation shows not only how to do this but also samples of how to update in just a few lines. ResultSet (Java Platform SE 6)

  16. #16
    Junior Member
    Join Date
    Jun 2013
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Aggravating project, need fresh eyes and help

    The update code block, as it is, runs without errors and updates as intended. The finally block - I see your point on that one, edited those in.

    Our coursework didn't cover prepared statements, and I'm... frankly, a little too overwhelmed right now. Resultset - got that, editing that in, too.

    On looking at it, I'm wondering if I need to do too much more to it. The problem with the updating is that the three types (graduate, undergrad, parttime) all have different sets of information that need to be updated. All of them have the basic set (firstname, lastname, gpa, mentor, studentid) but graduate adds in (thesistitle, thesisadvisor) and parttime adds (company). I can't think of a way to properly update without using the current system. The other student I spoke to used a similar setup and his project passed, so I think I might throw it to the reviewers and see if they will take it.

    And of course I run into more issues.

    private void deleteStudent(){
    	Connect gc = new Connect();
            Statement stmt = null;
            Connection conn = gc.getSimpleConnection();
            try
            {
                stmt = conn.createStatement();
                System.out.println("Enter Student ID:");
                while (!scan.hasNextInt()) {
                scan.next();
                }
                int id = scan.nextInt();
                scan.nextLine();
                stmt.execute("Delete FROM student WHERE studentID=" + "'" + id + "'");
     
                stmt.close();
                conn.close();
            }
             catch (SQLException e)
             {
                e.printStackTrace();
                System.err.println("Could not delete student");
     
             }
            System.out.println("Successfully deleted student from the database");
        }

    This is my current delete student code block. When I try to move the conn.close(); etc outside into a finally block, it red-lines it and wants to surround it by a try/catch block or add a "throws SQL" to the constructor. But when I do THAT, the case set up top doesn't like it because deleteStudent(); no longer matches. God, what a headache.

Similar Threads

  1. Replies: 12
    Last Post: May 8th, 2012, 05:22 PM
  2. Fresh Meat
    By SerratedMind in forum Member Introductions
    Replies: 2
    Last Post: September 15th, 2011, 05:13 AM
  3. i'm a fresh NIIT java student
    By femoozer in forum Member Introductions
    Replies: 2
    Last Post: August 20th, 2011, 02:12 PM
  4. Another pair of eyes.
    By Ripcurl in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 28th, 2010, 10:49 AM