Faulty Service in Apache Tomcat WebService

不问归期 提交于 2020-01-15 06:44:49

问题


I am getting faulty services in my apache tomcat web service after adding this method in the web service:

public String getAllEvent() {
    JSONArray jsonArray = new JSONArray();
    try {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection(
                "jdbc:mysql://localhost/mydb", "root", "root");

        PreparedStatement statement = con
                .prepareStatement("SELECT * FROM event");
        ResultSet result = statement.executeQuery();

        while (result.next()) {
            JSONObject eventInfo = new JSONObject();
            eventInfo.put("eventID", result.getString("eventID"));
            eventInfo.put("eventName", result.getString("eventName"));
            eventInfo.put("eventDesc", result.getString("eventDesc"));
            eventInfo.put("eventDate", result.getString("eventDate"));
            eventInfo.put("eventTime", result.getString("eventTime"));
            eventInfo.put("eventX", result.getString("eventX"));
            eventInfo.put("eventY", result.getString("eventY"));
            eventInfo.put("eventBy", result.getString("eventBy"));
            jsonArray.put(eventInfo);
        }
        String jsonStr = jsonArray.toString();
        return jsonStr;
    }

    catch (JSONException je) {
        return null;
    } catch (Exception exc) {
        System.out.println(exc.getMessage());
    }

    return jsonArray.toString();
}

For this method, I am passing the data retrieved from database into JSON. After I added it, when I run the web service on server, I am getting this error message:

Faculty Services:
C:\Users\Desktop\Eclipse EE\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\SplashWebService\WEB-INF\services\SplashWebService

The web service runs perfectly again after I removed this method. Any ideas?

Thanks in advance.

来源:https://stackoverflow.com/questions/26715533/faulty-service-in-apache-tomcat-webservice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!