Android Open Source - FoodFinderApp Async Add Restaurant To D B






From Project

Back to project page FoodFinderApp.

License

The source code is released under:

GNU General Public License

If you think the Android project FoodFinderApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package cs499.examples.semesterproject;
/*from w  ww  .j  a v a 2 s. c  om*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.widget.Toast;

public class AsyncAddRestaurantToDB extends AsyncTask <String, String, String>
{
  Connection c = null;
  Statement s = null;
  HashMap<String,String> h;
  Activity activityContext;
  ProgressDialog progressDialog;
  int queryExecuted = 0;
  String query = "";
  
  public AsyncAddRestaurantToDB (Activity activityContext, HashMap<String,String> h)
  {
    this.activityContext = activityContext;
    this.h = h;
  }

  @Override
  protected String doInBackground(String... params) 
  {
    this.postRestaurantInfo();
    return "Done";
  }

  @Override
  protected void onPreExecute() 
  {
    progressDialog = new ProgressDialog (activityContext);
    progressDialog.setMessage("Adding your restaurant/place info...");
    progressDialog.show();
  }
  
  private void postRestaurantInfo()
  {
    try 
    {
      Class.forName("oracle.jdbc.driver.OracleDriver");
    } 
    
    catch (ClassNotFoundException e) 
    {
      System.out.println("Where is your Oracle JDBC Driver?");
      e.printStackTrace();
      return;
    }
    
    try
    {
      c = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.8:1521/XE", "system", "admin");
      s = c.createStatement();
      
      query = "insert into foodappuser (username, password) values (" + h.get("foodPlaceOwnerName") + h.get("foodPlaceOwnerPassword") + ")";
      queryExecuted = s.executeUpdate(query);
      
      c.close();
      s.close();
    }
    catch (SQLException e) 
    {

      System.out.println("Program Failed! Check output console");
      e.printStackTrace();
      return;
    }
  }
  
  protected void onPostExecute ()
  {
     if (this.progressDialog.isShowing())
     {
       this.progressDialog.dismiss();
     }
    }

}




Java Source Code List

cs499.examples.semesterproject.AddItemsActivity.java
cs499.examples.semesterproject.AndroidFoodBankOwnerServlet.java
cs499.examples.semesterproject.AsyncAddItems.java
cs499.examples.semesterproject.AsyncAddPlace.java
cs499.examples.semesterproject.AsyncAddRestaurantToDB.java
cs499.examples.semesterproject.AsyncAuthenticateUser.java
cs499.examples.semesterproject.AsyncSearchAndShowPlaces.java
cs499.examples.semesterproject.AsyncSearchItems.java
cs499.examples.semesterproject.AsyncSendRequest.java
cs499.examples.semesterproject.AsyncViewRequests.java
cs499.examples.semesterproject.Constants.java
cs499.examples.semesterproject.DisplayMap.java
cs499.examples.semesterproject.DisplayMatchingPlaces.java
cs499.examples.semesterproject.DisplayPlaceItems.java
cs499.examples.semesterproject.DisplayPlace.java
cs499.examples.semesterproject.DisplayRequestActivity.java
cs499.examples.semesterproject.FoodBankOwnerActivity.java
cs499.examples.semesterproject.FoodOwnerOptions.java
cs499.examples.semesterproject.LoginActivity.java
cs499.examples.semesterproject.MainActivity.java
cs499.examples.semesterproject.OrganizationOptions.java
cs499.examples.semesterproject.OtherOwnerActivity.java
cs499.examples.semesterproject.QueryActivity.java
cs499.examples.semesterproject.ViewRequests.java
org.json.CDL.java
org.json.CookieList.java
org.json.Cookie.java
org.json.HTTPTokener.java
org.json.HTTP.java
org.json.JSONArray.java
org.json.JSONException.java
org.json.JSONML.java
org.json.JSONObject.java
org.json.JSONString.java
org.json.JSONStringer.java
org.json.JSONTokener.java
org.json.JSONWriter.java
org.json.Kim.java
org.json.Property.java
org.json.XMLTokener.java
org.json.XML.java
org.json.zip.BitInputStream.java
org.json.zip.BitOutputStream.java
org.json.zip.BitReader.java
org.json.zip.BitWriter.java
org.json.zip.Compressor.java
org.json.zip.Decompressor.java
org.json.zip.Huff.java
org.json.zip.JSONzip.java
org.json.zip.Keep.java
org.json.zip.MapKeep.java
org.json.zip.None.java
org.json.zip.PostMortem.java
org.json.zip.TrieKeep.java