Posts

Image
  JDBC 5: IMPORTANT Inside the parent table/class (exhibition), define a constructor which contains one argument as a list of all the records in the child table (stall) related to each exhibition. See the code for clarification. public class Stall { private Long id;     private String name;     private String detail;     private String owner;     private Exhibition exhibition;     public Stall(){}     public Stall(Long id,String name,String detail,String owner,Exhibition exhibition){         this.id=id;         this.name=name;         this.detail=detail;         this.owner=owner;         this.exhibition=exhibition;     }     public Long getId(){         return this.id;     }     public String getName(){         return this.name;     }...
Image
  JDBC 4: (WHERE CLAUSE, INSERTING, RETREIVING)    public class User {     private Long id;     private String name;     private String mobileNumber;     private String username;     private String password;     public User(){}     public User(Long id,String name, String mobileNumber, String username, String password){         this.id=id;         this.name=name;         this.mobileNumber=mobileNumber;         this.username=username;         this.password=password;     }     public User(Long id) {         this.id=id;     }     public Long getId()     {         return this.id;     }     public String getName(){         return this.name;     }     public String...
Image
  JDBC 3: (inserting) public class User{     private Long id;     private String name;     private String contactDetail;     private String username;     private String password;          public User(){}          public User(String name,String contactDetail,String username,String password){         this.name = name;         this.contactDetail = contactDetail;         this.username = username;         this.password = password;     }          public User(Long id,String name,String contactDetail,String username,String password){         this.id =id;         this.name = name;         this.contactDetail = contactDetail;         this.username = username;         this.password = ...
Image
  JDBC 2: public class User { //your code goes here...     private Long id;     private String name;     private String contactDetail;     private String username;     private String password;          public User(){}     public User(Long id,String name,String contactDetail,String username,String password){         this.id = id;         this.name  = name;         this.contactDetail = contactDetail;         this.username = username;         this.password = password;     }          public Long getId(){         return id;     }     public void setId(Long id){         this.id = id;     }     public String getName(){         return name;     }   ...
Image
  JDBC 1: _____________________________________________________________________ public class ItemType{          Long id;     String name;     Double deposit;     Double costPerDay;          ItemType(){ }     ItemType(Long id, String name, Double deposit, Double costPerDay){         this.id = id; this.name = name; this.deposit = deposit; this.costPerDay = costPerDay;         }          public String getName() {     return name;     }     public void setName(String name) {     this.name = name;     }               public Double getDeposit() {     return deposit;     }     public void setDeposit(Double deposit) {     this.deposit = deposit;     }    ...
SERIALIZATION CUSTOMER:  An Object can be directly saved into a file and can be later reloaded. This process is called Serialization and the restoration is called De-serialization. The extension of the file is ".ser". An Object is considered ready for serialization if its class implements a Serializable interface. The serializable interface is called Marker Interface. A Marker Interface is one that has no methods and member variables, but just indicates / marks that the given class is implementing the Interface. Use ObjectOutputStream class for converting an object to a serialized file. Input and Output Format: Enter the Customer name John Enter the Customer number 12 Enter the Customer address Chennai CODE: import java.io.Serializable; public class Customer implements Serializable {     private String name; private Integer number; private String address; public Customer() { super(); // TODO Auto-generated constructor stub } public Customer(String name, In...
Image
  JAVA Streams and Writers: ITEMTYPE DETAILS IN FILE The length and position of attributes are as follows.   Attribute Length Position name 15 1 deposit 7 16 costPerDay 5 22 Input format: Read the details from the input file  " input.txt " Output format: Use " %-15s %-15s %s\n " for displaying ItemType details in tabular form in the console Print one digit after the  decimal  for the  double  datatype. Print the statement for the heading of the details is  present  in the main method. Refer to the sample output for the formatting specifications. Sample Input: Sample Output : Item type       Deposit         Cost per day Electrical      2100.0          500.0 Construction    5000.0          1000.0 CODE: public class ItemType {   ...