如何在soap Web服务中检索数据库行?

时间:2016-05-12 18:27:11

标签: android web-services soap

我正在开发android中的移动应用程序。应用程序使用soap web服务(在java中)从数据库(在SQL Server中)获取数据。现在我遇到了一个问题,如下所示 - android应用程序从数据库中检索一行(所有列)并将列值设置为相应的文本字段,但我不知道该怎么做网络服务。请帮帮我

我的网络方法代码是 -

@WebMethod(operationName = "DiseaseInfoGC")

public String DiseaseInfo4( @WebParam(name = "crop_name") String crop, 
                            @WebParam(name = "spread_mode") String spread_mode,
                            @WebParam(name = "path_cong_env") String path_cong_env) {

    query_disease = new String();

    try {

        DBConnect.databaseconnect();
        Statement stmt_disease = DBConnect.connect.createStatement();
        query_disease = "Select * from Disease where crop_name='" + crop + "' and Disease_SpreadMode='"+spread_mode+"' "
                + "and Disease_PathCongEnv='" + path_cong_env + "'";
        System.out.println(query_disease);

        ResultSet rslt_disease = stmt_disease.executeQuery(query_disease);
        System.out.println(query_disease);

        executemyquery(rslt_disease);
  System.out.println(query_disease);
    } catch (ClassNotFoundException ex) {
        System.out.println(ex.getMessage());
    } catch (SQLException ex) {
        System.out.println(ex.getMessage());;
    } catch (NullPointerException ex) {
        System.out.println(ex.getMessage());
    }
    return disease_name;
}

executequery()是 -

  private void executemyquery(ResultSet rslt_disease) throws SQLException {
    while (rslt_disease.next()) {
        disease_name = rslt_disease.getString("Disease_EngName");
        System.out.println("Name Of the Disease: "+disease_name);
        path_name = rslt_disease.getString("Disease_PathScName");
        System.out.println("Name of the Pathogen: "+path_name);
        path_geo_dis = rslt_disease.getString("Disease_PathGeoDist");
        System.out.println("Pathogen Scientific name: "+path_geo_dis);
        path_life_cycle = rslt_disease.getString("Disease_PathLCycle");
        System.out.println("Life Cycle of the Pathogen: "+path_life_cycle);
        disease_symptoms = rslt_disease.getString("Disease_Symptom");
        System.out.println("Disease Symptoms: "+disease_symptoms);
        disease_controls = rslt_disease.getString("Disease_Control");
        System.out.println("Disease control mechanism: "+disease_controls);
        prevention = rslt_disease.getString("Disease_Prevention");
        System.out.println("Disease prevention Mechanism: "+prevention);
        spread_mode = rslt_disease.getString("Disease_SpreadMode");
        System.out.println("Spread mode of the disease: "+spread_mode);
        primary_source = rslt_disease.getString("Disease_PSource");
        System.out.println("Primary Source: "+primary_source);
        secondary_source = rslt_disease.getString("Disease_SSource");
        System.out.println("Secondary Source: "+secondary_source);
        path_a_host = rslt_disease.getString("Disease_PathAHost");
        System.out.println("Pathogen host"+path_a_host);
        path_cong_env = rslt_disease.getString("Disease_PathCongEnv");
        System.out.println("Pathogen Congenial Envoronment"+path_cong_env);
        occur_period = rslt_disease.getString("Disease_OccurancePd");
        System.out.println("Disease occuring period: "+occur_period);

    }

我刚刚将列值存储在字符串中。我知道在这里使用字符串是无用的。但我不知道如何在Web方法中存储数据库中的列值,以便我可以在Android应用程序中使用它们。希望你能理解我的问题。请指导我..

0 个答案:

没有答案