Back to project page foodroid.
The source code is released under:
GNU General Public License
If you think the Android project foodroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * To change this template, choose Tools | Templates * and open the template in the editor.//from w w w .ja v a2s . c om */ package com.wmc.Registration; import java.io.StringWriter; import javax.ws.rs.PathParam; import java.sql.*; import javax.ws.rs.Path; import javax.ws.rs.GET; import javax.ws.rs.Produces; import javax.xml.bind.JAXB; /** * REST Web Service * * @author Administrator */ @Path("FoodList") public class FoodListResource { @GET @Path("{branch}") @Produces("application/xml") public String getXml(@PathParam( "branch" ) String branch) { String result=""; Connection connection = null; PreparedStatement lookupFood = null; try { Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection(Settings.DATABASE_URL, Settings.DATABASE_USER, Settings.DATABASE_PASS); lookupFood = connection.prepareStatement("SELECT * FROM food where BranchID=" + branch); ResultSet resultSet = lookupFood.executeQuery(); result = Settings.generateXML(resultSet); } catch(SQLException e) { result= "error"; } catch (ClassNotFoundException cE) { result= "error"; System.out.println("Class Not Found Exception: "+ cE.toString()); } catch(Exception e) { result= "error"; e.printStackTrace(); } finally { try{ lookupFood.close(); connection.close(); } catch(Exception e) { e.printStackTrace(); } } StringWriter writer = new StringWriter(); JAXB.marshal( result, writer ); return writer.toString(); } }