1 / 18

Connecting to a MySQL Database

Connecting to a MySQL Database. presented by David Black. GOAL.

olwen
Download Presentation

Connecting to a MySQL Database

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Connecting to a MySQL Database presented by David Black

  2. GOAL • The goal of this tutorial is to teach you how to connect to a MySQL database using an HTTP client on an Android device. This being the case, we must prepare a MySQL database ahead of time on a remote server as well as a server-side script to perform our desired queries to the database. • The goal of this tutorial is not to teach you how to create a MySQL database or a server-side script. Therefore, these will be shown only as necessary to aid in your understanding of the Android Application. Topics such as database creation and safe querying practices fall outside the intended scope of this tutorial.

  3. FIRST THINGS FIRST! NEW OBJECT TYPES! • HttpClient (link) • HttpPost(link) • HttpResponse (link) • HttpEntity (link) • JSONObject (link)

  4. HTTPCLIENT • Interface for an HTTP client. HTTP clients encapsulate a smorgasbord of objects required to execute HTTP requests while handling cookies, authentication, connection management, and other features. Thread safety of HTTP clients depends on the implementation and configuration of the specific client.

  5. HTTPPOST • The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions: • Annotation of existing resources • Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles • Providing a block of data, such as the result of submitting a form, to a data-handling process • Extending a database through an append operation

  6. HTTPRESPONSE • An HTTP response.

  7. HTTPENTITY • An entity that can be sent or received with an HTTP message. Entities can be found in some requests and in responses, where they are optional.

  8. JSONObject • A modifiable set of name/value mappings. Names are unique, non-null strings. Values may be any mix of JSONObjects, JSONArrays, Strings, Booleans, Integers, Longs, Doubles or NULL. Values may not be null, NaNs, infinities, or of any type not listed here.

  9. THE GAMEPLAN

  10. THE DATABASE • Database Name: Login • Table Name: USER • Content:

  11. CHANGES TO THE MANIFEST • Because our Android Application will attempt to connect to an external database using Hypertext Transfer/Transport Protocol (HTTP), we must give permission for our Application to access the internet. To do so, we add the following line to the manifest tag:

  12. THE UI LinearLayout: llSampleLogin EditText: etUsername EditText: etPassword Button: bLogin

  13. THE JAVA

  14. THE ONCLICK LISTENER

  15. THE PHP FILE

  16. BACK TO THE JAVA

  17. DEMONSTRATION

  18. FILES ON D2L • AndroidManifest.xml • Main.xml • Strings.xml • Login.java • Index.php

More Related