Created
January 31, 2013 07:52
-
-
Save fanjavaid/4681125 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void getDoctorData() { | |
DoctorService doctorService = new DoctorService(); | |
List<Doctor> list = doctorService.selectAll(); | |
Vector vecModel = new Vector(); | |
for (Doctor doctor : list) { | |
String name = doctor.getFirstname()+" "+doctor.getLastname(); | |
int id = doctor.getId(); | |
vecModel.addElement(new Doctor(id, name)); | |
} | |
ComboBoxModel model = new DefaultComboBoxModel(vecModel); | |
cmbDoctor.setModel(model); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select All Data | |
public List<Doctor> selectAll() { | |
Statement stmt = null; | |
ResultSet rs = null; | |
List<Doctor> doctors = new ArrayList<>(); | |
try { | |
stmt = conn.createStatement(); | |
rs = stmt.executeQuery(selectAll); | |
while (rs.next()) { | |
Doctor doctor = new Doctor(); | |
doctor.setId(rs.getInt("uid")); | |
doctor.setTitle(rs.getString("title")); | |
doctor.setFirstname(rs.getString("firstname")); | |
doctor.setLastname(rs.getString("lastname")); | |
doctor.setSpecialist(rs.getString("specialist")); | |
doctors.add(doctor); | |
} | |
return doctors; | |
} catch (SQLException se) { | |
se.printStackTrace(); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment