Chapter 16

Database Client



Universal TeacherIn this chapter, we will look at the client side of this database application.

Files needed for this chapter are:

  • (Main form)
  • (Represents a student)
  • (Visual form for entering information)

The Student Class

Listing 16.1


//Class used to represent a student.
public class Student
	implements Serializable{
	//Instance variables.
	private int rollNumber;
	private String name,course;
	public Student(int rollNumber, 
		String name,String course){
		//Initialize the variables.
		this.rollNumber = rollNumber; = name;
		this.course = course;
	//{{ Accessor methods }} //
	//method used to get roll number.
	public int getRollNumber(){
		return rollNumber;
	//method used to get name.
	public String getName(){
		return name;
	//method used to get course
	public String getCourse(){
		return course;
	//{{Mutator methods }}//
	//method used to set roll number.
	public void setRollNumber(int rollNumber){
		this.rollNumber = rollNumber;
	//method used to set name.
	public void setName(String name){ = name;
	//method used to set course.
	public void setCourse(String course){
		this.course = course;
	//Returns a string representation of the object. 
	public String toString(){
		return "RollNumber: " +rollNumber +
			 " Name: " + name +
			 " Course : " + course;

Explanation of Code

This class represents a student. Objects of this class will be passed across the network. The class is not remote, so its methods can not be invoked remotely. Note that the Student class implements the interface. Therefore, objects of this class can be transported from one machine to another, but the receiving machine will get the copy of the actual object.

The Constructor of the class takes three arguments:

  • Roll number of the student.
  • Name of the student.
  • Course for which the student is registered.

Further, the class provides some accessor and mutator methods.




RMI BOOK MAIN PAGE                Top

Copyright © 2001