Example a list of contacts
This presentation is the property of its rightful owner.
Sponsored Links
1 / 13

Example – a list of contacts PowerPoint PPT Presentation


  • 79 Views
  • Uploaded on
  • Presentation posted in: General

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

Download Presentation

Example – a list of contacts

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


  • Login