Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!

shane ocon

Greenhorn
+ Follow
since Jan 25, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by shane ocon

Hi,
Were doing a hospital admin system where the hospital admin can enter a new patients details and save them to a ms access DB.
For this we created Data Access Objects.

We must have the ability to SELECT, ADD, DELETE and UPDATE the Db.
So far we have managed 3 but cannot figure out how to Update the DB.
Heres some of my ADD code:
public class PatientDAO
{

/** Creates a new instance of AdminADO */
public PatientDAO() {
}

public void select()
{
Connection con = null;
Patient patient = null;
Vector<Patient> patients = new Vector();

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=hospital.mdb";
con = DriverManager.getConnection(database,"","");
Statement stmt = con.createStatement();
ResultSet results = stmt.executeQuery("Select * from Patient");


while (results.next())
{
patient = new Patient();
patient.setPatientID(results.getString("Patient_ID"));
patient.setFName(results.getString("PF_Name"));
patient.setSName(results.getString("PS_Name"));
patient.setAddress(results.getString("Address"));
patient.setContact(results.getString("ContactNo"));
patient.setBP(results.getString("BloodPressure"));
patient.setTemp(results.getString("Temperature"));
patient.setBedNo(results.getString("BedNumber"));
patient.setWardID(results.getString("Ward_ID"));
patient.setDoctorID(results.getString("Doctor_ID"));
patient.setObservations(results.getString("Observations"));
patient.setMedicalFile(results.getString("MedicalFile"));

patients.add(patient);
}

for(Patient p :patients)
{
System.out.print(p.getPatientID()) ;
System.out.print(p.getFName()) ;
System.out.print(p.getSName()) ;
System.out.print(p.getAddress()) ;
System.out.println(p.getContactNo()) ;
System.out.print(p.getBP()) ;
System.out.print(p.getTemp()) ;
System.out.print(p.getBedNo()) ;
System.out.println(p.getWardID()) ;
System.out.println(p.getDoctorID()) ;
System.out.println(p.getObservations()) ;
System.out.println(p.getMedicalFile()) ;
}
}

catch(ClassNotFoundException e)
{
System.out.println(e.toString());
}

catch(SQLException e)
{
System.out.println(e.toString());
}

}
public void insert(Patient p)
{
Connection con1=null;

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=hospital.mdb";
con1 = DriverManager.getConnection(database,"","");

PreparedStatement newpatient = con1.prepareStatement("INSERT INTO Patient(Patient_ID, PF_Name, PS_Name ,Address, ContactNo, BloodPressure, Temperature, BedNumber, Ward_ID, Doctor_ID, Observations, MedicalFile,)VALUES(?,?,?,?,?,?,?,?,?,?,?,?)");

newpatient.setString(1,p.getPatientID());
newpatient.setString(2,p.getFName());
newpatient.setString(3,p.getSName());
newpatient.setString(4,p.getAddress());
newpatient.setString(5,p.getContact());
newpatient.setString(6,p.getBP());
newpatient.setString(7,p.getTemp());
newpatient.setString(8,p.getBedNo());
newpatient.setString(9,p.getWardID());
newpatient.setString(10,p.getDoctorID());
newpatient.setString(11,p.getObservations());
newpatient.setString(12,p.getMedicalFile());


newpatient.executeUpdate();
System.out.println("***Patient Added***");
//CLOSE
con1.close();

}

catch(SQLException e)
{
System.out.println(e.toString());
}

catch(ClassNotFoundException e)
{
System.out.println(e.toString());
}

}
}

Then, here is the main method*****************

public class PatientTest {

/** Creates a new instance of Main */
public PatientTest() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

PatientDAO patientDAO = new PatientDAO();


Patient p = new Patient();
p.setAddress("Glanmire");
p.setContact("021-4822236");
p.setFName("Daniel");
p.setSName("Whelan");
p.setPatientID("1");
p.setWardID("Ward 1");
p.setTemp("56 degrees");
p.setBP("12");
p.setBedNo("Bed 2");
p.setDoctorID("1");
p.setObservations("Head Ache and Sore throat");
p.setMedicalFile("this is a medical file...input here");

patientDAO.insert(p);
patientDAO.select();

}

}

Any ideas on how i could update the DB now
PLEASE, PLEASE, please help

Thanks alot
Ok thanks for replying your prob right...

i found the code as below...is this image coming from a url on the net???
i want it to come from a folder...
class BackgroundPanel extends JPanel
{
Image image;
public BackgroundPanel()
{
try
{
image = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Test.gif"), "Test.gif"));
}
catch(Exception e){/*handled in paintComponent()*/}
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
if(image != null) g.drawImage(image, 0,0,this.getWidth(),this.getHeight(),this);
}
}
14 years ago
Please could any one help me...i know there are previous posts on this topic but i cannot understand what is going on in any of them as im a total beginner...
I want to display an image as the background on a jpanel...
Could anyone give me an example of the easiest and simplest code for this..

tanx in advanz
14 years ago
can anyone help me here...
I am trying to get this peice of code working from the site below....

http://www.java-tips.org/java-se-tips/javax.swing/wrap-a-swing-jcomponent-in-a-background-image.html

Well i have got it working its just...when i try to maximise the application the image stays at its original size.

What can i do to get the image to maximise to the full screen with the app. aswel???

Any help will be ~REALLY~ helpful!!!
thanks
14 years ago