Results 1 to 2 of 2

Thread: Database

  1. #1
    mcnam4119 is offline Member
    Join Date
    Sep 2010
    Location
    Singapore
    Posts
    13
    Rep Power
    0

    Unhappy Database

    this is my classes code(i call this in my main)

    import java.io.*;
    import java.util.*;
    public class NameAgeDatabaseClass {

    public NameAgeDatabaseClass() {
    }


    BufferedReader buff=new BufferedReader(new InputStreamReader(System.in));
    public void menu()throws IOException
    {
    System.out.println("**********Student Database**********");
    System.out.println("1. Add Student to Database");
    System.out.println("2. Edit Student in Database");
    System.out.println("3. Delete Student from Database");
    System.out.println("4. View Student's in Database");
    System.out.println("5. Exit Student Database");
    System.out.println("Pick a Menu option");
    int choose= Integer.parseInt (buff.readLine());
    }

    public void addStudent()throws IOException
    {
    FileWriter fwAdd=new FileWriter("C:\\Test.txt",false);
    PrintWriter output=new PrintWriter(fwAdd);
    System.out.println("Enter the name of the Student");
    output.println(buff.readLine());
    output.println("");
    System.out.println("Enter the age of the Student");
    output.println(Integer.parseInt (buff.readLine()));
    output.println("");
    output.close();
    fwAdd.close();
    }

    public void viewStudent()throws IOException
    {
    File myFile=new File("C:\\Test.txt");
    Scanner sf=new Scanner(myFile);
    System.out.println("*-*-*-*Student Database*-*-*-*");
    System.out.println("Name: Age: ");
    while(sf.hasNext())
    {
    System.out.println(sf.nextLine());
    }
    sf.close();
    }

    public void editStudent()throws IOException
    {

    }

    public void deleteStudent()throws IOException
    {

    }

    switch(choose)
    {
    case 1: //add student
    addStudent();
    break;

    case 2: //edit student
    //editStudent();
    break;

    case 3: //view student database
    viewStudent();
    break;

    case 4: //delete student
    //deleteStudent();
    break;
    }


    }

    this is my main code

    mport java.io.*;
    import java.util.*;
    public class NameAgeDatabase {

    public static void main(String[] args)throws IOException {

    NameAgeDatabaseClass student=new NameAgeDatabaseClass();
    student.menu();







    }
    }

    What i am having trouble with is the deleting and editing of records without the use of arrays, i can do it with arrays but without i am unsure. (I am also using file handling if you didnt pick it up alredy)

  2. #2
    mcnam4119 is offline Member
    Join Date
    Sep 2010
    Location
    Singapore
    Posts
    13
    Rep Power
    0

    Default

    My switch function also doesnt work but i can do that myself its a simple fix

Similar Threads

  1. xml to database from xml rpc
    By kievari in forum JDBC
    Replies: 1
    Last Post: 12-11-2009, 12:14 AM
  2. Database Help
    By simtology in forum New To Java
    Replies: 3
    Last Post: 08-18-2009, 03:03 PM
  3. What database shall i use?
    By etherkye in forum JDBC
    Replies: 13
    Last Post: 06-26-2009, 06:03 PM
  4. help with database
    By fahien_akim in forum NetBeans
    Replies: 0
    Last Post: 03-07-2009, 01:44 PM
  5. Replies: 2
    Last Post: 02-11-2009, 04:43 AM

Tags for this Thread

Posting Permissions

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