Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | BDB Java Sample Program Backing enterprise and embedded Java applications with BDB.

Slides:



Advertisements
Similar presentations
Phoenix We put the SQL back in NoSQL James Taylor Demos:
Advertisements

Connecting to Databases. connecting to DB DB server typically a standalone application Server runs on localhost for smaller sites –i.e. Same machine as.
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
CE881: Mobile and Social Application Programming Flexible Data Handling with Integrity: SQLite Simon M. Lucas.
Elephant: A Persistent Metaobject Protocol and Object Oriented Database for Common Lisp Persistent object protocol –persistent-metaclass specializes slot.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | BDB-DICOM Sample Program Capturing and using large data objects with BDB Berkeley.
GridGain In-Memory Data Fabric:
HOL9396: Oracle Event Processing 12c
Oracle SQL*plus John Ortiz. Lecture 10SQL: Overview2 Overview  SQL: Structured Query Language, pronounced S. Q. L. or sequel.  A standard language for.
SQLLite and Java CS-328 Dick Steflik. SQLLite Embedded RDBMS ACID Compliant Size – about 257 Kbytes Not a client/server architecture –Accessed via function.
SQLite and the.NET Framework This PPT:
SQLite 1 CS440. What is SQLite?  Open Source Database embedded in Android  SQL syntax  Requires small memory at runtime (250 Kbytes)  Lightweight.
Confidential ODBC May 7, Features What is ODBC? Why Create an ODBC Driver for Rochade? How do we Expose Rochade as Relational Transformation.
1 Lecture 18 George Koutsogiannakis/Spring 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
The Java Persistence API Edel Sherratt. Contents Revisit applications programming Using Java Persistence API.
Databases Dan Otero Alex Loddengaard
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
ODBC Open DataBase Connectivity a standard database access method developed by Microsoft to access data from any application regardless of which database.
Object Persistence and Object-Relational Mapping James Brucker.
By Mihir Joshi Nikhil Dixit Limaye Pallavi Bhide Payal Godse.
1 Java Database Connection (JDBC) There are many industrial-strength DBMS's commercially available in the market. Oracle, DB2, and Sybase are just a few.
JDBC Java Database Connectivity. What is an RDBMS? Relational database management system. There are other kinds of DBMS. Access is a GUI on a JET RBDMS.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
October 30, 2007S. Weigert / Y. HAN1 Working with Eclipse-Ingres RUBIS Autumn 2007.
Announcements Read JDBC Project Step 5, due Monday.
DB Libraries: An Alternative to DBMS By Matt Stegman November 22, 2005.
© D. Wong  Indexes  JDBC  JDBC in J2EE (Java 2 Enterprise Edition)
Midterm Exam Chapters 1,2,3,5, 6,7 (closed book) March 11, 2014.
Fundamentals of Database Chapter 7 Database Technologies.
M1G Introduction to Database Development 6. Building Applications.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
Hive Facebook 2009.
SQLite Cole Hoosier Overview  RDBMS –Relational database management system  ACID Compliant –Atomicity, consistency, isolation, durability.
Revolutionizing enterprise web development Searching with Solr.
NoSQL Databases Oracle - Berkeley DB Rasanjalee DM Smriti J CSC 8711 Instructor: Dr. Raj Sunderraman.
NoSQL Databases Oracle - Berkeley DB. Content A brief intro to NoSQL About Berkeley Db About our application.
Overview of JDBC and Pro*C 1 CSE 5330 – Database Systems.
 What software components are required?  How do I install the Oracle JDBC driver?  How do I connect to the database?  What form is the data in and.
Creating and using Persistent Data From before – Where does the data come from? – Why is it kept? – How is it used? Affects design and implementation choices.
Android Storage. There are several options for storage of data with Android We can put data into a preferences file. We can put data into a ‘normal’ file.
Copyright 2008 Judith A Copeland - Accessing The Database By Judi Copeland.
Introduction to the new mainframe © Copyright IBM Corp., All rights reserved. Chapter 12 Understanding database managers on z/OS.
Hibernate 3.0. What is Hibernate Hibernate is a free, open source Java package that makes it easy to work with relational databases. Hibernate makes it.
Topic : Hibernate 2: Object Persistence and ORM Kaster Nurmukan.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
Fall CIS 764 Database Systems Engineering L18.2 : Object Relational Mapping … ….Object persistence.
Mobile Software Development ISCG 7424 Department of Computing UNITEC John Casey and Richard Rabeder SQLite and Permissions.
WEB SERVER SOFTWARE FEATURE SETS
Basics of JDBC Session 14.
Technology Drill Down: Windows Azure Platform Eric Nelson | ISV Application Architect | Microsoft UK |
Getting Started with Oracle Berkeley DB 11gR2 and ADO.NET
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Hibernate Online Training. Introduction to Hibernate Hibernate is a high-performance Object-Relational persistence and query service which takes care.
CHAPTER 9 File Storage Shared Preferences SQLite.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 1.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
JDBC. Database is used to store data permanently. These days almost all Applications needs database to store its data persistently. Below are the most.
3 Copyright © 2006, Oracle. All rights reserved. Designing and Developing for Performance.
16 Copyright © 2004, Oracle. All rights reserved. Testing the Migrated Oracle Database.
12 Copyright © 2004, Oracle. All rights reserved. Application Migration: Overview.
Database Programming Basic JDBC Programming Concepts.
Top 10 Entity Framework Features Every Developer Should Know
Web Technologies IT230 Dr Mohamed Habib.
Open Source distributed document DB for an enterprise
Chapter 14 Geodatabases.
HW#4 Making Simple BBS Using JDBC
PHP / MySQL Introduction
Android Storage.
IST 311 Object-Oriented Design and Software Applications
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Presentation transcript:

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | BDB Java Sample Program Backing enterprise and embedded Java applications with BDB Berkeley DB 1

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Berkeley DB A high-performance key-value database – Designed for high-throughput applications requiring in-process, bullet-proof management of mission-critical data – Scale gracefully from managing a few bytes to terabytes of data Full ACID transaction support – Concurrent transactional operations with multiple isolation levels – Full transactional recovery support Cursor and secondary index support – Fast and flexible data access Cross platform support Berkeley DB2

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Berkeley DB for Java Why Java? – Cross platform, write once run everywhere – Scale gracefully from tiny embedded devices to clustered enterprise applications How? – Base key-value API – Direct persistence layer (DPL) API – JDBC API Berkeley DB3

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Base key-value API Lower level API – Full control over persisted data format – Resemble closely to the C API – Work with Java 4+ – More verbose Handles – Environment – Database – Cursor Berkeley DB4

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Base key-value API - Example Opening the environment and database EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setInitializeCache(true); envConfig.setInitializeLocking(true); envConfig.setInitializeLogging(true); envConfig.setTransactional(true); Environment env = new Environment(“envHome”, envConfig); DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(true); dbConfig.setType(DatabaseType.BTREE); Database db = env.openDatabase(null, “myDatabase.db”, null, dbConfig); Berkeley DB5

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Base key-value API – Example cont. Writing and getting values with binding DatabaseEntry key = new DatabaseEntry(); DatabaseEntry value = new DatabaseEntry(); TupleBinding keyBinding = TupleBinding.getPrimitiveBinding(Long.class); TupleBinding valueBinding = TupleBinding.getPrimitiveBinding(String.class); keyBinding.objectToEntry(1L, key); valueBinding.objectToEntry(“value”, value); db.put(null, key, value); // get the same value back DatabaseEntry dbValue = new DatabaseEntry(); db.get(null, key, dbValue, LockMode.DEFAULT); String strValue = valueBinding.entryToObject(dbValue); Berkeley DB6

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Base key-value API – Example cont. Using cursors DatabaseEntry key = new DatabaseEntry(); DatabaseEntry value = new DatabaseEntry(); TupleBinding keyBinding = TupleBinding.getPrimitiveBinding(Long.class); TupleBinding valueBinding = TupleBinding.getPrimitiveBinding(String.class); keyBinding.objectToEntry(1L, key); Cursor cur = db.openCursor(null, null); OperationStatus status = cur.getSearchKey(key, value, LockMode.DEFAULT); if (status == OperationStatus.SUCCESS) String strValue = valueBinding.entryToObject(dbValue); Berkeley DB7

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Direct persistence layer API Higher level API – Work with objects instead of key-value pairs – Use annotation, less cluttered code – Work better with relatively static schema – Require Java 5+ Core classes – EntityStore – PrimaryIndex/SecondaryIndex – EntityCursor Berkeley DB8

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Direct persistence layer API - Example Opening the environment and entity store EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setInitializeCache(true); envConfig.setInitializeLocking(true); envConfig.setInitializeLogging(true); envConfig.setTransactional(true); Environment env = new Environment(“envHome”, envConfig); StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(true).setTransactional(true); EntityStore store = new EntityStore(env, name, storeConfig); Berkeley DB9

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Direct persistence layer API – Example cont. Annotate entity public class Ticket private Long ticketId; private String meterId; public Ticket() {} public Ticket(Long id, String mId) { ticketId = id; meterId = mId; } public Long getTicketId() { return ticketId; } public String getMeterId() { return meterId; } } Berkeley DB10

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Direct persistence layer API – Example cont. Writing and getting objects PrimaryIndex index = store.getPrimaryIndex(Long.class, Ticket.class); index.put(new Ticket(1L, “myTicket”)); Ticket ticket = index.get(1L); Using cursors EntityCursor cursor = index.entities(); for (Ticket t : cursor) String meterId = t.getMeterId(); Berkeley DB11

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | JDBC API Use SQLite dialect Support JDBC 4 Work with Java 4 - Java 7 JDBC URL jdbc:sqlite:/ Berkeley DB12

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | The sample program The story – Simulates a parking lot with one parking meter OLTP & OLAP – Ticket transactions (CRUD) follow the OLTP paradigm – Operational analysis (BI/Data mining) follow the OLAP paradigm Cross platform/IDE support – Linux / Unix / Windows – IntelliJ / Eclipse / JDeveloper Berkeley DB13

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | The sample program – cont. Support all three APIs – Base key-value API – DPL API – JDBC API Cover many features – Transaction – Cursor – Primary and secondary index Berkeley DB14

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | The sample program – Data model TICKET ( TICKET_ID INTEGER PRIMARY KEY, METER_ID TEXT, ISSUE_TIME INTEGER) TICKET_LOG( LOG_TIME INTEGER PRIMARY KEY, METER_ID TEXT, TICKET_ID INTEGER, ACTION TEXT, CHARGE_FEE INTEGER) SEQUENCE “TICKET_ID_SEQ” INDEX METER_IDX ON TICKET_LOG(METER_ID, LOG_TIME) Berkeley DB15

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | The sample program – Data access layer DbManager – Manages an environment or a JDBC connection – Manages transactions – Creates DAOs TicketDAO – CRUD operations on Tickets TicketLogDAO – Append TicketLogs and query TicketLogs given a meterId and a period Berkeley DB16

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | The sample program – Application components Meter – Represent a parking meter – Create Tickets and compute parking fees Reporting – Represent a BI reporting module – Create reports using TicketLog queries Driver – A demo driver program Berkeley DB17

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | The sample program - Run General steps: – Build the following Berkeley DB components on your platform Core SQL API Java API JDBC API – Import the sample program into your IDE – Configure the project’s build path to include the Java and JDBC jars – Configure ‘java.library.path’ to point to native Berkeley DB libraries in your run configuration Berkeley DB18

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Resources We need to figure out where to put the following and add that here – Code – Word & PPT – 5 videos Main (PPT + code walk through) BDB build 3 IDEs Berkeley DB19