example a list of contacts
Download
Skip this Video
Download Presentation
Example – a list of contacts

Loading in 2 Seconds...

play fullscreen
1 / 13

Example – a list of contacts - PowerPoint PPT Presentation


  • 107 Views
  • Uploaded on

Example – a list of contacts. See Contact.java at http://www.aber.ac.uk/~dcswww/Dept/Teaching/CourseNotes/current/CS12230/codeExamples/0-simple-examples/Contact.java What if we want the contacts data to persist?. Contact – OO model. UML class diagram Attributes name and phone

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Example – a list of contacts' - melosa


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
example a list of contacts
Example – a list of contacts
  • See Contact.java at
  • http://www.aber.ac.uk/~dcswww/Dept/Teaching/CourseNotes/current/CS12230/codeExamples/0-simple-examples/Contact.java
  • What if we want the contacts data to persist?
contact oo model
Contact – OO model
  • UML class diagram
  • Attributes name and phone
  • Operation toString()
contact er model
Contact – ER model
  • Just the attributes
  • No operations
  • Still a UML class diagram
k ey value pairs
Key-value pairs
  • Name is the key
  • Phone is the value
  • Data model is a kind of persistent hash table
storage choices
Storage choices
  • Text file
  • Spreadsheet
  • Browser
  • Database
    • Relational
    • Object oriented
    • NoSQL
    • Native XML
browser
Browser
  • HTML5 localStorage
  • localStorage.setItem(key, value)
  • localStorage.getItem(key)
  • For offline use, use appcache
  • Benefits
  • Limitations
  • Example
sqlite
SQLite
  • Create the SQLite database
  • http://www.sqlite.org/
  • Use a shell tool – a convenient way to create the database in the first place
  • Or write a program
applications programming with sql cli
Applications Programming with SQL/CLI
  • Obtain a handle on the database
  • Send SQL queries to the database management system using query functions
  • Process the results of those queries
    • Results are tables and must be transformed into types that the application program can use
java jdbc image from http www cse unsw edu au jas talks jdbc notes html accessed 15 oct 2012
Java JDBCimage from http://www.cse.unsw.edu.au/~jas/talks/jdbc/notes.htmlaccessed 15/Oct/2012
java jdbc
Java JDBC
  • Driver manager provides implementations of Connection, Statement and ResultSet
  • Connection acts as database handle
  • Statement enables creation and execution of SQL queries
  • ResultSet maintains a cursor that enables access to current row of data returned by query
sqlite with java jdbc
SQLite with Java JDBC
  • Suppose you have a database and a jdbc driver
  • In your Java program
    • Initialize the jdbcdriver Class.forName("org.sqlite.JDBC");causes org.sqlite.JDBC to be loaded at runtime
    • Get a connection this.connection= DriverManager.getConnection("jdbc:sqlite:"+dbname);
    • Use the connection to send SQL queries to the database
  • Contacts example
java persistence api
Java Persistence API
  • Alternative to call level interface
  • Work directly with the object oriented data model
  • We’ll revisit this later in the course
summary
Summary
  • First think about
    • Where the data comes from
    • Why the data is stored
    • How it is to be used
  • Then think about
    • Data models
    • Data storage options
    • Applications programming
ad