Results 1 to 2 of 2
Thread: Database
- 12-10-2010, 03:56 AM #1
Member
- Join Date
- Sep 2010
- Location
- Singapore
- Posts
- 13
- Rep Power
- 0
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)
- 12-10-2010, 03:57 AM #2
Member
- Join Date
- Sep 2010
- Location
- Singapore
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
xml to database from xml rpc
By kievari in forum JDBCReplies: 1Last Post: 12-11-2009, 12:14 AM -
Database Help
By simtology in forum New To JavaReplies: 3Last Post: 08-18-2009, 03:03 PM -
What database shall i use?
By etherkye in forum JDBCReplies: 13Last Post: 06-26-2009, 06:03 PM -
help with database
By fahien_akim in forum NetBeansReplies: 0Last Post: 03-07-2009, 01:44 PM -
How to convert access database to mysql database?
By vrk in forum Advanced JavaReplies: 2Last Post: 02-11-2009, 04:43 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks