Introduction to Apache Derby, TS-3154, Javaone Conference 2006

Introduction to Apache Derby, TS-3154, Javaone Conference 2006

Introduction to Apache Derby Dan Debrunner Senior Technical Staff Member IBM David Van Couvering Senior Staff Engineer Sun TS-3154 Copyright © 2006, Sun Microsystems Inc., All rights reserved. 2006 JavaOneSM Conference | Session TS-3154 | Where Would You Like Your Data? Learn more about Apache Derby, the database that can go anywhere 2 2006 JavaOneSM Conference | Session TS-3154 | Agenda Overview What Is Derby Good For? Derby Architecture 3 2006 JavaOneSM Conference | Session TS-3154 | Overview ● Derby enables data anywhere ● A complete database in a small package ● Mature, robust, performant, supported ● Community-based open source 4 2006 JavaOneSM Conference | Session TS-3154 | With Apache Derby, Your Data Can Go Anywhere In a browser, memory stick, laptop, server machine, mainframe, PDA... —anywhere Java™ technology goes 5 2006 JavaOneSM Conference | Session TS-3154 | How Does Derby Do This? ● Pure Java technology ● Easy to use ● Embeddable and client/server ● Small footprint ● Secure 6 2006 JavaOneSM Conference | Session TS-3154 | A Complete Database in a Small Package TM ● JDBC Optional Package for CDC/Foundation Profile (JSR 169) ● SQL92 and SQL99 ● Java based procedures, triggers, referential constraints, fully transactional with recovery ● Online backup/restore ● Database encryption ● 2 MB runtime footprint 7 2006 JavaOneSM Conference | Session TS-3154 | Java Technology in Your Database CREATE FUNCTION SEND_MAIL( TO_ADDRESS VARCHAR(320), SUBJECT VARCHAR(320), BODY VARCHAR(32000)) RETURNS INT LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL EXTERNAL NAME 'testing.MailTest.sendSMTP_F'; -- Send a Welcome e-mail when new customers are added. CREATE TRIGGER WELCOME_CUSTOMER AFTER INSERT ON CUSTOMER REFERENCING new_table AS newtab FOR EACH STATEMENT MODE DB2SQL SELECT SEND_MAIL(c.email, 'Welcome to AcmeWidgets', M.email_text) FROM newtab C, MAILINGS M WHERE C.TYPE = M.CUST_TYPE AND M.OFFER_TYPE = 'welcome' 8 2006 JavaOneSM Conference | Session TS-3154 | A SQL Function in Java Technology public static int sendSMTP_F (String toAddress, String subject, String content) { recipient = new InternetAddress(toAddress); ... msg = new MimeMessage(session); msg.setFrom(from); msg.setSubject(subject); msg.setText(content); msg.addRecipient(Message.RecipientType.TO, recipient); javax.mail.Transport.send(msg); return 0; } See http://wiki.apache.org/db-derby/SendEmailRoutine 9 2006 JavaOneSM Conference | Session TS-3154 | Mature and Supported ● In production since 1997 ● In use by numerous products ● http://wiki.apache.org/db-derby/UsesOfDerby ● Supported versions from Sun and IBM 10 2006 JavaOneSM Conference | Session TS-3154 | Derby Performs ● Comparable with other open source databases ● Outperforms MySQL on large databases ● MySQL better on small main-memory database ● No significant performance loss with client/server, except for SELECT operations ● See http://tinyurl.com/nxmj8 ● Ongoing improvements ● Tips ● Prepared statements, cache size, indices 11 2006 JavaOneSM Conference | Session TS-3154 | Derby Holds a Lot of Data ● Theoretical limit is 2^64 bytes per table and 2^64 tables ● Testing up to 250GB in 10.2 release ● Near-term goal: test up to 1 TB 12 2006 JavaOneSM Conference | Session TS-3154 | You Can Get Involved! ● Apache Community ● Anyone can contribute ● http://db.apache.org/derby 13 2006 JavaOneSM Conference | Session TS-3154 | What Is Derby Good For? ● Browser local store ● Middle-tier cache ● Database on the go ● Read-only database ● Easy-to-manage departmental database ● Development and unit testing 14 2006 JavaOneSM Conference | Session TS-3154 | Deploy Derby Invisibly in a Browser Browser Process Web Page (JavaScriptTM Technology) DataService derby.jar (Java Object) 15 2006 JavaOneSM Conference | Session TS-3154 | Example Use Cases ● Store sensitive data on user machine ● Offline web mail or blogs ● Local cache ● Retain state even if browser exits 16 2006 JavaOneSM Conference | Session TS-3154 | How Derby Makes This Work ● Embedded ● Invisible ● 2 MB Footprint ● Compressible to 600k, see http://blogs.sun.com/roller/page/FrancoisOrsini/20060118 ● Secure ● Fast 17 2006 JavaOneSM Conference | Session TS-3154 | DEMO Running Derby embedded in a browser For code and details, see http://developers.sun.com/prodtech/javadb/ 18 2006 JavaOneSM Conference | Session TS-3154 | Derby as a Local Cache Local Host Remote Host A Web/App Server App Derby Remote Host B Synchronizer 19 2006 JavaOneSM Conference | Session TS-3154 | Embedding Derby Connection conn = DriverManager.getConnection ("jdbc:derby:sample"); 20 2006 JavaOneSM Conference | Session TS-3154 | Enabling Embedded Derby For Clients ● In derby.properties file: derby.drda.startNetworkServer=true 21 2006 JavaOneSM Conference | Session TS-3154 | A Database That Can Go Anywhere ● Laptop, PDA, memory stick ● Small footprint ● No DBA ● Secure ● Java technology 22 2006 JavaOneSM Conference | Session TS-3154 | Example Use Cases ● Metadata store for digital media collection ● Integrate with Open Office ● Store sensitive data off disk ● Retain critical data in emergency ● Up-to-date conference schedule on a stick 23 2006 JavaOneSM Conference | Session TS-3154 | DEMO Derby on a Stick 24 2006 JavaOneSM Conference | Session TS-3154 | Read-Only Database ● Can be placed onto CD-ROM ● Can put inside your JAR/EAR/WAR file 25 2006 JavaOneSM Conference | Session TS-3154 | Example Use Cases ● Sales or product catalog on CD-ROM ● Auto-updated local cache of sales price list on sales laptop 26 2006 JavaOneSM Conference | Session TS-3154 | Read-Only Database in a JAR ● Add database directory to your JAR jar uvf myapp.jar salesCatalog ● Put JAR file on classpath ● Connect using standard JDBC Connection conn = DriverManager.getConnection (“jdbc:derby:/salesCatalog”); 27 2006 JavaOneSM Conference | Session TS-3154 | Easy to Manage Departmental DB App Client App Client App Client Derby Network Server Derby 28 2006 JavaOneSM Conference | Session TS-3154 | Starting Derby Network Server now startnetworkserver.[bat|ksh] future java -jar derbynet.jar start 29 2006 JavaOneSM Conference | Session TS-3154 | Java Technology Development and Unit Testing ● Embedded ● JDBC 3 and 4 software, SQL92 and SQL99 ● Full multi-user support ™ ● Integrated plugin for Eclipse, NetBeans software 30 2006 JavaOneSM Conference | Session TS-3154 | Engine Architecture ● Layered ● Modular ● Cost-based optimizer ● Queries compiled into byte-code ● Fully transactional and recoverable 31 2006 JavaOneSM Conference | Session TS-3154 | Layered Architecture Embedded JDBC Software Layer Monitor SQL Query Query Execution Compiler Services Virtual Transactional Store Table Interface 32 2006 JavaOneSM Conference | Session TS-3154 | Pluggable Infrastructure Store Access Interface Heap BTree RTree? ... Store Raw Interface Data Log Transactions Configurable Encryption Using JCE File Jar HTTP Memory Anything System 33 2006 JavaOneSM Conference | Session TS-3154 | SQL Optimizer ● Preprocess compilation phase ● Internal query modifications ● Aimed at giving optimize phase more choices ● Plans selected by cost estimates ● Data distribution statistics automatically maintained ● ORDER-BY eliminations for index scans ● Optimizer Overrides ● SELECT * FROM --DERBY-PROPERTIES joinOrder=FIXED t1, t2 WHERE t1.c1=t2.c1 34 2006 JavaOneSM Conference | Session TS-3154 | SQL Compiled to Java Byte Code SELECT * FROM CUSTOMER WHERE ID = ? Connection 1 java.lang.Class org.apache.derby.exe.ac3442 java.lang.ClassLoader org.apache.derby.<internal class> java.sql.PreparedStatement Activations, instances of org.apache.derby.<internal class> org.apache.derby.exe.ac3442 Connection 2 Application Derby Internals 35 2006 JavaOneSM Conference | Session TS-3154 | Transaction Logging ● Aries logging system for rollback and recovery ● Order of a change—write ahead logging ● Crash recovery automatically executed 36 2006 JavaOneSM Conference | Session TS-3154 | Summary ● You can use Apache Derby to put your data anywhere ● Small, but fully functional engine ● Lots of great uses ● Community-based open source ● Open standards 37 2006 JavaOneSM Conference | Session TS-3154 | For More Information SM ● Apache Derby JavaOne Conference Event ● http://db.apache.org/derby ● http://www.ibm.com/developerworks/cloudscape ● http://developers.sun.com/prodtech/javadb/ ● Book: Apache Derby—Off to the Races 38 2006 JavaOneSM Conference | Session TS-3154 | Q&A 39 2006 JavaOneSM Conference | Session TS-3154 | Introduction to Apache Derby Dan Debrunner Senior Technical Staff Member IBM David Van Couvering Senior Staff Engineer Sun TS-3154 2006 JavaOneSM Conference | Session TS-3154 | .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    40 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us