package objects; public class Student { private int studno; private String lastname; private String firstname; private
String address; private String degree; public static void main(String[] args) { new Student(); } public int getStudno() { return studno; } public void setStudno(int studno) { [Link] = studno; } public String getLastname() { return lastname; } public void setLastname(String lastname) { [Link] = lastname; } public String getFirstname() { return firstname; } public void setFirstname(String firstname) { [Link] = firstname; } public String getAddress() { return address; } public void setAddress(String address) { [Link] = address; }
public String getDegree() { return degree; } public void setDegree(String degree) { [Link] = degree; } }
package gui;
import [Link].*;
import [Link];
import [Link];
import [Link].*; import [Link].*; import [Link]; import [Link];
public class FrameMain extends JFrame implements ActionListener { private JPanel topP, bottomP, leftP, rightP; private JLabel enterL, searchL, studnoL, lastL, firstL, addressL, degreeL; private JTextField enterTF, studnoTF, lastTF, firstTF, addressTF, degreeTF; private JButton searchB, addB, editB, deleteB, saveB;
private EmbeddedSQLConnection ec = new EmbeddedSQLConnection(); private Student student = new Student();
public FrameMain() { setSize(350, 250); setTitle("Last Project");
Container mp = getContentPane(); [Link](new BorderLayout());
//top panel
topP = new JPanel(); [Link](new FlowLayout());
enterL = new JLabel("Enter Last name"); enterTF = new JTextField(10);
searchB = new JButton("Search"); [Link](this);
[Link](enterL); [Link](enterTF); [Link](searchB);
//left panel leftP = new JPanel(); [Link](new GridLayout(5,1));
studnoL = new JLabel("Student Number", [Link]); lastL = new JLabel("Last Name", [Link]); firstL = new JLabel("First Name", [Link]); addressL = new JLabel("Address", [Link]); degreeL = new JLabel("Degree", [Link]);
[Link](studnoL); [Link](lastL); [Link](firstL); [Link](addressL); [Link](degreeL);
//right panel
rightP = new JPanel(); [Link](new GridLayout(5,1));
studnoTF = new JTextField(10); lastTF = new JTextField(10); firstTF = new JTextField(10); addressTF = new JTextField(10); degreeTF = new JTextField(10);
[Link](studnoTF); [Link](lastTF); [Link](firstTF); [Link](addressTF); [Link](degreeTF);
//bottom panel
bottomP = new JPanel(); [Link](new GridLayout(1,4));
addB = new JButton("Add"); [Link](true); [Link](this);
editB = new JButton("Edit"); [Link](true); [Link](this);
deleteB = new JButton("Delete"); [Link](true); [Link](this);
saveB = new JButton("Save"); [Link](false); [Link](this);
[Link](addB); [Link](editB); [Link](deleteB); [Link](saveB);
//container [Link](topP, [Link]); [Link](leftP, [Link]); [Link](rightP, [Link]); [Link](bottomP, [Link]);
setVisible(true); } public static void main(String [] args) { new FrameMain(); }
public void actionPerformed(ActionEvent e) { String action = [Link](); if([Link]("Search")) { [Link](); [Link](student, [Link]()); showStudent(); } else if([Link]("Add")) { [Link](false); [Link](true); [Link](""); clearTF(); }
else if([Link]("Save")) { [Link](); [Link]([Link]([Link]())); [Link]([Link]()); [Link]([Link]()); [Link]([Link]()); [Link]([Link]());
[Link](student); [Link]();
[Link](false); clearTF(); } else if([Link]("Edit")) { [Link](); [Link]([Link]([Link]())); [Link]([Link]()); [Link]([Link]()); [Link]([Link]()); [Link]([Link]());
[Link](true);
[Link]();
[Link](false);
} else if([Link]("Delete")) { [Link](); [Link]([Link]([Link]())); [Link]([Link]()); [Link]([Link]()); [Link]([Link]()); [Link]([Link]());
[Link](true); [Link](true);
[Link](); clearTF();
} private void clearTF() { [Link](""); [Link](""); [Link](""); [Link](""); [Link]("");
} private void showStudent()
{ [Link]([Link]()+""); [Link]([Link]()); [Link]([Link]()); [Link]([Link]()); [Link]([Link]());
} }
package database; import [Link].*;
import [Link];
public class EmbeddedSQLConnection { private Connection con;
public EmbeddedSQLConnection() {
public void getConnection() {
try { [Link]("[Link].DB2Driver");
con=[Link]("jdbc:db2://localhost:50000/sample", "denzel", "lanzdenzel"); } catch (Exception e) { // TODO Auto-generated catch block [Link]();
public boolean getStudentInformation(Student stud, String lastname) {
try { PreparedStatement s = null; String query = "SELECT studno, lastname, firstname, address, degree FROM student WHERE lastname=?"; s=[Link](query);
[Link](1, lastname);
ResultSet rs = [Link]();
while([Link]()) { [Link]([Link](1)); [Link]([Link](2)); [Link]([Link](3)); [Link]([Link](4)); [Link]([Link](5));
} catch (SQLException e) { // TODO Auto-generated catch block [Link](); }
return true; }
public boolean addStudent(Student stud) {
PreparedStatement s = null; String query = "INSERT into student VALUES(?,?,?,?,?)"; try { s=[Link](query); [Link](1, [Link]()); [Link](2, [Link]());
[Link](3, [Link]()); [Link](4, [Link]()); [Link](5, [Link]());
[Link](); } catch(SQLException e) { [Link](); } return true; } public boolean deleteStudent(Student stud, String lastname) { try { PreparedStatement s = null; String query = "SELECT studno, lastname, firstname, address, degree FROM student WHERE lastname=?";
[Link](1, lastname);
ResultSet rs = [Link]();
while([Link]()) { [Link]([Link](1)); [Link]([Link](2)); [Link]([Link](3));
[Link]([Link](4)); [Link]([Link](5));
} catch (SQLException e) { // TODO Auto-generated catch block [Link](); }
return true; } public boolean editStudent(Student stud) { PreparedStatement s = null; String query = "UPDATE student set studno=?,lastname=?,firstname=?,address=?,degree=? where studno=?"; try { s=[Link](query); [Link](1, [Link]()); [Link](2, [Link]()); [Link](3, [Link]()); [Link](4, [Link]()); [Link](5, [Link]());
[Link](); } catch(SQLException e)
{ [Link](); } return true; }
public void closeConnection() { try { [Link](); con=null; } catch (SQLException e) { // TODO Auto-generated catch block [Link](); }