Package com.youtube.dao

Examples of com.youtube.dao.Schema308tube


    Response rb = null
    JSONArray json = new JSONArray();
   
    try {
     
      Schema308tube dao = new Schema308tube();
     
      json = dao.queryAllPcParts();
      returnString = json.toString();
     
      rb = Response.ok(returnString).build();
     
    }
View Full Code Here


  public Response addPcParts2(String incomingData) throws Exception {
   
    String returnString = null;
    JSONArray jsonArray = new JSONArray();
    JSONObject jsonObject = new JSONObject();
    Schema308tube dao = new Schema308tube();
   
    try {
     
      /*
       * We can create a new instance and it will accept a JSON string
       * By doing this, we can now access the data.
       */
      JSONObject partsData = new JSONObject(incomingData);
      System.out.println( "jsonData: " + partsData.toString() );
     
      /*
       * In order to access the data, you will need to use one of the method in JSONArray
       * or JSONObject.  I recommend using the optXXXX methods instead of the get method.
       *
       * Example:
       * partsData.get("PC_PARTS_TITLE");
       * The example above will get you the data, the problem is, if PC_PARTS_TITLE does
       * not exist, it will generate a java error.  If you are using get, you need to use
       * the has method first partsData.has("PC_PARTS_TITLE");.
       *
       * Example:
       * partsData.optString("PC_PARTS_TITLE");
       * The optString example above will also return data but if PC_PARTS_TITLE does not
       * exist, it will return a BLANK string.
       *
       * partsData.optString("PC_PARTS_TITLE", "NULL");
       * You can add a second parameter, it will return NULL if PC_PARTS_TITLE does not
       * exist.
       */
      int http_code = dao.insertIntoPC_PARTS(partsData.optString("PC_PARTS_TITLE"),
                            partsData.optString("PC_PARTS_CODE"),
                            partsData.optString("PC_PARTS_MAKER"),
                            partsData.optString("PC_PARTS_AVAIL"),
                            partsData.optString("PC_PARTS_DESC") );
     
View Full Code Here

    int avail;
    int http_code;
    String returnString = null;
    JSONArray jsonArray = new JSONArray();
    JSONObject jsonObject = new JSONObject();
    Schema308tube dao = new Schema308tube();
   
    try {
     
      JSONObject partsData = new JSONObject(incomingData); //we are using json objects to parse data
      pk = partsData.optInt("PC_PARTS_PK", 0);
      avail = partsData.optInt("PC_PARTS_AVAIL", 0);
     
      //call the correct sql method
      http_code = dao.updatePC_PARTS(pk, avail);
     
      if(http_code == 200) {
        jsonObject.put("HTTP_CODE", "200");
        jsonObject.put("MSG", "Item has been updated successfully");
      } else {
View Full Code Here

    int pk;
    int http_code;
    String returnString = null;
    JSONArray jsonArray = new JSONArray();
    JSONObject jsonObject = new JSONObject();
    Schema308tube dao = new Schema308tube();
   
    try {
     
      JSONObject partsData = new JSONObject(incomingData);
      pk = partsData.optInt("PC_PARTS_PK", 0);
     
      http_code = dao.deletePC_PARTS(pk);
     
      if(http_code == 200) {
        jsonObject.put("HTTP_CODE", "200");
        jsonObject.put("MSG", "Item has been deleted successfully");
      } else {
View Full Code Here

      //return a error is brand is missing from the url string
      if(brand == null) {
        return Response.status(400).entity("Error: please specify brand for this search").build();
      }
     
      Schema308tube dao = new Schema308tube();
     
      json = dao.queryReturnBrandParts(brand);
      returnString = json.toString();
     
    }
    catch (Exception e) {
      e.printStackTrace();
View Full Code Here

   
    JSONArray json = new JSONArray();
   
    try {
     
      Schema308tube dao = new Schema308tube();
     
      json = dao.queryReturnBrandParts(brand);
      returnString = json.toString();
    }
    catch (Exception e) {
      e.printStackTrace();
      return Response.status(500).entity("Server was not able to process your request").build();
View Full Code Here

   
    JSONArray json = new JSONArray();
   
    try {
     
      Schema308tube dao = new Schema308tube();
     
      json = dao.queryReturnBrandItemNumber(brand, item_number);
      returnString = json.toString();
    }
    catch (Exception e) {
      e.printStackTrace();
      return Response.status(500).entity("Server was not able to process your request").build();
View Full Code Here

  @Produces(MediaType.APPLICATION_JSON)
  public Response addPcParts(String incomingData) throws Exception {
   
    String returnString = null;
    //JSONArray jsonArray = new JSONArray(); //not needed
    Schema308tube dao = new Schema308tube();
   
    try {
      System.out.println("incomingData: " + incomingData);
     
      /*
       * ObjectMapper is from Jackson Processor framework
       * http://jackson.codehaus.org/
       *
       * Using the readValue method, you can parse the json from the http request
       * and data bind it to a Java Class.
       */
      ObjectMapper mapper = new ObjectMapper()
      ItemEntry itemEntry = mapper.readValue(incomingData, ItemEntry.class);
     
      int http_code = dao.insertIntoPC_PARTS(itemEntry.PC_PARTS_TITLE,
                          itemEntry.PC_PARTS_CODE,
                          itemEntry.PC_PARTS_MAKER,
                          itemEntry.PC_PARTS_AVAIL,
                          itemEntry.PC_PARTS_DESC );
     
View Full Code Here

TOP

Related Classes of com.youtube.dao.Schema308tube

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.