Package com.mysql.jdbc

Examples of com.mysql.jdbc.ResultSet


    public void releaseConnection(){
        dbConn.closeConnection();
    }
   
    public ResultSet getPatient(int patientID){
        ResultSet res = null;
        try {
            String command;
            command = "SELECT * FROM patients WHERE id = "+ patientID;
            res = dbConn.executeQuery(command);
        } catch (Exception ex) {
View Full Code Here


        }
        return res;
    }

    public ResultSet getDoctor(int doctorID){
        ResultSet res = null;
        try {
            String command;
            command = "SELECT * FROM doctors WHERE id = "+ doctorID;
            res = dbConn.executeQuery(command);
        } catch (Exception ex) {
View Full Code Here

        return res;
    }

   
    public ResultSet getPatientVaccinations(int patientID){
        ResultSet res = null;
        try {
            String command;
            command = "SELECT * FROM (SELECT * FROM vaccinations LEFT JOIN doctors ON id = doctor_id ) AS X "
                    + "WHERE patient_id = " + patientID;
            res = dbConn.executeQuery(command);
View Full Code Here

        }
        return res;
    }

    public ResultSet getDoctorVaccinations(int doctorID) {
        ResultSet res = null;
        try {
            String command;
            command = "SELECT patient_id, vaccination_date FROM vaccinations WHERE doctor_id = " + doctorID;
            ResultSet set1 = dbConn.executeQuery(command);
            command = "SELECT name, surname FROM patients WHERE patient_id = " + set1.getString("patient_id");
            ResultSet set2 = dbConn.executeQuery(command);
            command = "SELECT name, surname, vaccination_date FROM " + set1.getCursorName() + " JOIN " + set2.getCursorName();
            res = dbConn.executeQuery(command);
            return res;
        } catch (SQLException ex) {
            Log4k.error(dbManager.class.getName(), ex.getMessage());
        }
View Full Code Here

    public String getDBtime(){
        String res = null;
        try {
            String command = "SELECT NOW() AS N";
            ResultSet set = dbConn.executeQuery(command);
            set.next();
            res = set.getString("N");
        } catch (SQLException ex) {
            Log4k.error(dbManager.class.getName(), ex.getMessage());
        }
        return res;
    }
View Full Code Here

    private String getDBdiffTime(int sec) {
        String res = null;
        try {
            String command = "SELECT NOW() - INTERVAL " + sec + " SECOND AS C";           
            ResultSet set = dbConn.executeQuery(command);
            set.next();
            res = set.getString("C");           
        } catch (SQLException ex) {
            Log4k.error(dbManager.class.getName(), ex.getMessage());
        }
        return res;
    }
View Full Code Here

        }
        return res;
    }

    public ResultSet getPreviousVaccinationsPatients(int sec){
        ResultSet res = null;
        try {
            String command;
            /* Select the last vaccination of each vaccinated patient before sec seconds ago */
            String lastVaccinations = "SELECT DISTINCT MAX(vaccination_date) AS 'max', patient_id AS 'pid' FROM vaccinations GROUP BY patient_id";
            String JT1 = "SELECT * " +
View Full Code Here

        }
        return res;
    }
   
    public ResultSet getFollowingVaccinationsPatients(int sec){
        ResultSet res = null;
        try {
            String command;
            String lastVaccinations = "SELECT DISTINCT MAX(vaccination_date) AS 'max', patient_id AS 'pid' FROM vaccinations GROUP BY patient_id";
            String JT1 = "SELECT * " +
                    "FROM patients LEFT JOIN (" + lastVaccinations + ") AS last_vaccinations " +
View Full Code Here

    }
   
    public void doRegister(String username, String new_pwd) throws NotInDBException, YetRegisteredException{
        try {
            String command;
            ResultSet resSet;
           
            { /* Check wheter a user is both present and already registered into the DB */
                command = "SELECT registered FROM patients WHERE username = '" + username + "'";
                resSet = dbConn.executeQuery(command);
                if (resSet.first()){
                    boolean isYetRegistered_str = resSet.getBoolean("registered");
                    if (isYetRegistered_str) throw new YetRegisteredException();
                } else {
                    throw new NotInDBException();
                }
            }
View Full Code Here

            Log4k.error(dbManager.class.getName(), ex.getMessage());
        }
    }
   
    public ResultSet userMatches(String userName, String pwd, boolean isDoctor){
        ResultSet res;
        String userKind = ((isDoctor) ? "doctor" : "patient");
        String command = "SELECT * FROM " + userKind + "s WHERE "
                + "username = '" + userName + "' AND "
                + "password = '" + pwd + "' AND "
                + ((isDoctor) ? " TRUE" : "registered");
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.ResultSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.