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 . j av a 2 s .co m*/ */ package com.wmc.Registration; import javax.ws.rs.Path; import javax.ws.rs.GET; import javax.ws.rs.Produces; import javax.xml.bind.JAXB; import java.io.StringWriter; import java.sql.*; import javax.ws.rs.PathParam; @Path("branchlist") public class BranchlistResource { @GET @Path("{id}") @Produces("application/xml") public String getXml(@PathParam( "id" ) String id) { String result=""; Connection connection = null; PreparedStatement lookupBranch = null; //PreparedStatement registerUser = null; try { Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection(Settings.DATABASE_URL, Settings.DATABASE_USER, Settings.DATABASE_PASS); String sqlStr = "SELECT * FROM branch "; if(!id.equals("*")) sqlStr += " where ID=" + id; lookupBranch = connection.prepareStatement(sqlStr); ResultSet resultSet = lookupBranch.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{ lookupBranch.close(); connection.close(); } catch(Exception e) { e.printStackTrace(); } } StringWriter writer = new StringWriter(); JAXB.marshal( result, writer ); return writer.toString(); } }