Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

UB 1.3.3 find & create

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some questions again:



1. String[] data is (key does not go to db, just index):
a) key,name,city..
b) name, city..
c) other, what?




It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.



2. String[] criteria contains (all fields must be used?)
a)name,location...
b)name,location
c) other, what?

3. I need to provide to GUI functionality
a) search with all fields
b) search with name and/or location
c) other, what?


And finally design points (comments?):

Uses DBCache, file is read in the beginning
  • synchronized Singleton
  • all member variables private

  • DBCache contains data + schema
  • used helper class to populate & read data
  • don't start if magic cookie don't match

  • DBRecords contains (in DBCache) (LinkedHashMap<Integer, DBRecords>):
  • index(record number),record(actual record)
  • one DBRecord contains(LinkedHashMap<Integer, String>
  • index (way to match against schema), value of the field


  • creation & find uses schema to determine field lengths + amount of fields in db-file (that's why i'm asking all these questions)

    Properties are read from file. Own class extends java.util.Properties
  • magic cookie (set/get)
  • db-file location (set/get)


  • Thanks

    ps. used time 8,5h
     
    Sheriff
    Posts: 11604
    178
    Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    looking good. used approximately the same approach

    concerning your questions about find and create. i guess they take both an array which contains as many fields as the db model. i check the length of the array to the db-model. if it's not the same i throw IllegalArgumentException

    and your find method will have to return more records than you might show in your gui, because you don't have an option if you have to search on (name and location) or (name or location). so you have to return all records starting with specified name or with the specified location. and in your business layer you have to filter the returned array depending on which choice the user made.
     
    Have you no shame? Have you no decency? Have you no tiny ad?
    Devious Experiments for a Truly Passive Greenhouse!
    https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
      Bookmark Topic Watch Topic
    • New Topic