Connecting netbeans with sql database
I've connected my database to netbeans and it automatically generated some code for me. This is one of the files of code it created.
Code :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package stud_info;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author vianna
*/
@Entity
@Table(name = "student")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Student.findAll", query = "SELECT s FROM Student s"),
@NamedQuery(name = "Student.findByStudId", query = "SELECT s FROM Student s WHERE s.studId = :studId"),
@NamedQuery(name = "Student.findByLastName", query = "SELECT s FROM Student s WHERE s.lastName = :lastName"),
@NamedQuery(name = "Student.findByFirstName", query = "SELECT s FROM Student s WHERE s.firstName = :firstName"),
@NamedQuery(name = "Student.findByGender", query = "SELECT s FROM Student s WHERE s.gender = :gender")})
public class Student implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "Stud_Id")
private Integer studId;
@Basic(optional = false)
@Column(name = "LastName")
private String lastName;
@Basic(optional = false)
@Column(name = "FirstName")
private String firstName;
@Basic(optional = false)
@Column(name = "Gender")
private String gender;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "studId")
private Collection<Address> addressCollection;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "studId")
private Collection<AcademicDetails> academicDetailsCollection;
public Student() {
}
public Student(Integer studId) {
this.studId = studId;
}
public Student(Integer studId, String lastName, String firstName, String gender) {
this.studId = studId;
this.lastName = lastName;
this.firstName = firstName;
this.gender = gender;
}
public Integer getStudId() {
return studId;
}
public void setStudId(Integer studId) {
this.studId = studId;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
@XmlTransient
public Collection<Address> getAddressCollection() {
return addressCollection;
}
public void setAddressCollection(Collection<Address> addressCollection) {
this.addressCollection = addressCollection;
}
@XmlTransient
public Collection<AcademicDetails> getAcademicDetailsCollection() {
return academicDetailsCollection;
}
public void setAcademicDetailsCollection(Collection<AcademicDetails> academicDetailsCollection) {
this.academicDetailsCollection = academicDetailsCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (studId != null ? studId.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Student)) {
return false;
}
Student other = (Student) object;
if ((this.studId == null && other.studId != null) || (this.studId != null && !this.studId.equals(other.studId))) {
return false;
}
return true;
}
@Override
public String toString() {
return "stud_info.Student[ studId=" + studId + " ]";
}
}
I want to use the database information to make array objects but I dont know where to go from there so that i can assign variables or even get the results of some of the functions in the automated code. Can someone please explain how I go about doing this please?
Re: Connecting netbeans with sql database