Invalid service in Apache Tomcat WebService
I am getting faulty services in apache tomcat webservice after adding this method to the webservice:
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 the database to JSON. After I added it, when I start the web service on the server, I get the following error:
Faculty Services:
C:\Users\Desktop\Eclipse EE\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\SplashWebService\WEB-INF\services\SplashWebService
The webservice works fine after I removed this method. Any ideas?
Thanks in advance.
+3
source to share
No one has answered this question yet
See similar questions:
or similar: