Sunday, July 20, 2014

not null value convert into null value in sql query

// Start Consultent
    public List getConsultentAppoinData(String valSpecial_name) {

        List<ReasonAppPatientInfo> consultentAppPatientList = new ArrayList<ReasonAppPatientInfo>();
        boolean fg = true;
        con = dbc.connectDB();

        Statement st1 = null;
        ResultSet rs1 = null;
        if (con == null) {
            fg = false;
        }

        String addCon = "is null";
        if (valSpecial_name != null) {
            addCon = "=" + valSpecial_name;
        }


        if (fg) {
            try {

                st1 = con.createStatement();

                String query1 = "select doctor_no,doctor_name,doc_chember from hpms_doctor where specialization_no "
                        + addCon;


                System.out.println(query1);

                rs1 = st1.executeQuery(query1);

                while (rs1.next()) {

                    ReasonAppPatientInfo reasonAppPatientInfo = new ReasonAppPatientInfo();
                    reasonAppPatientInfo.setDOCTOR_NO(rs1.getString("doctor_no"));
                    reasonAppPatientInfo.setDOCTOR_NAME(rs1.getString("doctor_name"));
                    reasonAppPatientInfo.setDOC_CHEMBER(rs1.getString("doc_chember"));
                    consultentAppPatientList.add(reasonAppPatientInfo);
                }

            } catch (SQLException sq) {
                sq.printStackTrace();
            } finally {
                try {
                    if (rs1 != null) {
                        rs1.close();
                    }

                    con.close();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }
            }
        }

        return consultentAppPatientList;
    }

    // End Consultent

No comments:

Post a Comment