Download introduction to sun java db

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
INTRODUCTION TO
SUN JAVA DB
Øystein Grøvlen
Java DB Architectural Lead
Sun Microsystems
[email protected]
1
Agenda
•
•
•
•
•
•
•
•
Sun Microsystems, Trondheim
Introduction to Java DB
Features
Configurations
Demos
Open-Source Community (Apache Derby)
Database Performance
Q&A
Sun Confidential: Internal Only
2
Sun Microsystems,
Trondheim
Suns utviklingsavdeling i Trondheim
●
●
●
●
En del av software-divisjonen
Database Center of Excellence
Flere produkter: HADB (Clustra), Java DB (Apache
Derby), PostgreSQL, memcached
46 ansatte, flesteparten utdannet ved NTNU (hvorav
9 med doktorgrad)
Sun Confidential: Internal Only
4
Internasjonalt miljø
• Trondheim,
Bangalore,
California
• Engelsk
• Samarbeid
• Åpen
kildekode
• Software global natur
• Kultur
Sun Confidential: Internal Only
5
Programmering
C/C++
Java SE
Java EE
Databaser
Åpen
kildekode
• Dyp
kompetanse
•
•
•
•
•
Sun Confidential: Internal Only
6
Infrastruktur og
Kvalitet
• Lab Engineering
• Quality Engineering,
testutvikling
• Quality Assurance,
generelt kvalitetsarbeid
• Release Engineering,
leveranser
Sun Confidential: Internal Only
7
Java DB –
Introduction
What is
?
• The database for Java
• Sun's supported distribution of Apache Derby
> Same source
> Same binaries
> Sun-supported
• Bundled in Sun JDK 6
• Open source database technology
• Derby is a sub-project of the Apache DB Project
Sun Confidential: Internal Only
9
Main Characteristics
•
•
•
•
•
•
•
Complete relational database engine
Embeddable and client/server database
Easy to use, zero maintenance
Small footprint (2MB)
Standards-based (JDBC, SQL92/99/2003)
Compact, secure, mature and robust
Pure Java (write once, run anywhere)
Sun Confidential: Internal Only
10
Java DB History
•
•
•
•
•
•
•
•
•
1996: Cloudscape founded – Release 1.0 97'
1999: Cloudscape acquired by Informix
2001: DB part of Informix acquired by IBM
2004: IBM donated Cloudscape to Apache as Derby
Early 2005: Sun starts contributing to Apache Derby
July 2005: Derby graduated from Apache Incubator
December 2005: Sun announces Java DB
December 2006: Java DB bundled in Sun JDK 6
Current release: 10.3.1 (August 2007)
Sun Confidential: Internal Only
11
Java DB in Sun Products
• Java DB is used by
>
>
>
>
Java Enterprise System
Java System Application Server (incl. Glassfish)
Java System Portal Server and
Service Registry
• Java DB is supported by Netbeans
• Sun offers support for Java DB
http://developers.sun.com/javadb/support/
• Bundled in Sun JDK 6
• Available standalone at:
http://developers.sun.com/javadb/downloads/
Sun Confidential: Internal Only
12
Java DB –
Features
Pure Java
• Database code written in Java
• Write Once Run Anywhere
> Requires a J2SE 1.4, J2SE 5.0, or Java SE 6 virtual
machine
> Any hardware, any operating system, any vendor
• Single binary runs everywhere
> Solaris, Solaris x86, Linux, FreeBSD, Windows, MacOs,
AIX, Z/OS, AS400, OS/390, …
• Database on-disk format is platform independent, too!
Sun Confidential: Internal Only
14
Small Footprint (Compact)
• Engine jar file is around 2MB
> Optional Jar files
– Network server ~150k
– Tools ~200k
• Runtime memory use
> Dependent on application, data caching etc.
> Can run when Java heap memory restricted to 4MB
> Have run in machines with only 16MB physical memory
• Engine jar can be compressed down to ~600K for
faster download (Java 5 Pack200)
http://blogs.sun.com/roller/page/FrancoisOrsini/20060118
Sun Confidential: Internal Only
15
Complete Relational Engine
• Multi-user, transactions, isolation levels, deadlock
detection, crash recovery
• SQL
> Tables, indexes, views, triggers, procedures, functions
> Foreign keys and check constraints
> Joins, cost based optimizer
• Data caching, statement caching, write ahead logging,
group commit
• Online backup/restore
• Database encryption
Sun Confidential: Internal Only
16
Java Stored Procedures/Functions
• SQL Standard part 13
• To call back into the DB engine, use Standard SQL
connection URL: jdbc:default:connection
• May call external Java functions from SQL.
Example:
CREATE FUNCTION COS(A DOUBLE) RETURNS DOUBLE
LANGUAGE JAVA PARAMETER STYLE JAVA
NO SQL EXTERNAL NAME ‘java.lang.Math.cos’
ij> VALUES COS(2.1);
1
----------------------0.5048461045998576
1 row selected
Sun Confidential: Internal Only
17
Security
• On-disk database encryption
• Built-in, LDAP, NIS+ and pluggable authentication
> Support for various network authentication mechanisms
> Authentication provider interface
• Support for strong network client authentication
> Derby network client driver
• ANSI grant/revoke privileges support
• Java Security Manager enabled by default
• SSL / TLS for encryption between client and server
Sun Confidential: Internal Only
18
Standards Based
• SQL
> SQL92, SQL99, SQL2003, SQL/XML, …
• Java
J2SE 1.3, 1.4, 5.0, Java SE 6
Java EE
JDBC 2.0 & 3.0 (4.0 as part of Java DB 10.2.2)
Java ME CDC (JSR 169) (JDBC for CDC)
• DRDA V3
> OpenGroup (http://www.opengroup.org/)
>
>
>
>
Sun Confidential: Internal Only
19
Java DB –
Configurations
Embedded Java DB
Java Virtual Machine
Application or
App/Web Server
JDBC
Java DB
Database(s)
on disk
• Database only accessible
from a single JVM
• Startup & shutdown
controlled by application
• Just one JAR file
• Invisible to the user
• Easy to use
• Zero administration
• Fast
Sun Confidential: Internal Only
21
Starting an Embedded Java DB
• No specific start-up code!
• Loading the JDBC driver starts the embedded
engine
• Making a connection request to the database starts
that database, if it was not already running
Sun Confidential: Internal Only
22
Start Up Code
String driverClassName =
“org.apache.derby.jdbc.EmbeddedDriver”;
String databaseURL = “jdbc:derby:dbName”;
// Load the JDBC Driver
Class.forName(driverClassName);
// Open a connection to the database
Connection conn =
DriverManager.getConnection(databaseURL);
Sun Confidential: Internal Only
23
JDBC Driver URL
• Format:
jdbc:derby:[database][;attribute=value]*
• Attributes: user, password, create, databaseName,
logDevice, territory, collation, encryption options, recovery
options
• To create a new database, connect with URL:
jdbc:derby:dbName;create=true
• Attributes can also be passed in the Properties
parameter of DriverManager.getConnection
methods.
Sun Confidential: Internal Only
24
Shutting Down an Embedded DB
• Do nothing – exiting VM will stop Java DB
> Recovery will be run on next start
• Shut down a single database
> Make a connection request to the database with URL:
jdbc:derby:dbName;shutdown=true
• Shut down all databases and the engine
> Make a connection request without a database name:
jdbc:derby:;shutdown=true
• Note: A connection request for shutdown will throw
an exception.
Sun Confidential: Internal Only
25
Client/Server
App
JDBC
App
JDBC
DRDA
Java VM
Network
Server
JDBC
Java DB
• Network Server uses
embedded driver against
Java DB
• Standard protocol
(DRDA). May use drivers
from other vendors.
• Scripts provided to start
and stop a Network
Server.
Database(s)
on disk
Sun Confidential: Internal Only
26
Avoid Network Server Security Risks
• Enable user authentication
• Run the network server with the Java 2 Security
Manager enabled (default in 10.3)
> Procedures and functions will have no permissions
> Application code can be granted permissions
• If Internet access is not needed, ensure your firewall
blocks the network server port
• May use SSL / TLS for encryption between client
and server
Sun Confidential: Internal Only
27
Embedded Network Server
App
JDBC
DRDA
Java VM
Network
App
Server
JDBC
Java DB
• Provides access to
database from outside the
application's VM.
• Adds DB reporting and
debugging capabilities to
stand-alone application
• No code changes to
application. Enabled by
setting property
derby.drda.startNetworkServer
Database(s)
on disk
Sun Confidential: Internal Only
28
Read only DB-in-a-jar (or zip)
Generate DB
application
Use DB
application
Embedded JDBC Driver
Embedded JDBC Driver
Java DB
Java DB
jar cvf db.jar foobar
Sun Confidential: Internal Only
29
DB-on-a-stick
Application
Embedded JDBC Driver
Java DB
Sun Confidential: Internal Only
30
DB in a Browser
Browser
Ajax
Applet
Embedded JDBC Driver
• Small enough to fit in a
browser
• Fast enough for interactive
use
• See demo at
http://developers.sun.com/javadb/
Java DB
Sun Confidential: Internal Only
31
Tools
• ij – Interactive SQL/Scripting tool
> JDBC neutral, can be used against other JDBC drivers
• dblook – schema extraction tool for Java DB
> Generates the DDL to be used to recreate database
schema
• sysinfo – Java DB version information
> Output useful for bug reporting in Jira
• Third party GUI tool
> SQuirreL
Sun Confidential: Internal Only
32
No separate SQL virtual machine
• SQL compiled into Java byte-code
• Run on standard Java VM
> Pro: Fast. Utilizes JIT compiler
> Con: Compilation + class-loading
SQL
HotSpot compiler
Query Parser & Compiler
Bytecode
Sun Confidential: Internal Only
Machine
instructions
33
Pluggable Storage Architecture
EmbeddedDriver / NetworkServer
Database Engine
Optional configurable encryption layer using JCE
File
System
Zip/Jar
Memory
Sun Confidential: Internal Only
HTTP?
...
34
Java DB –
Community
Apache Derby Community
• Apache Software License v2.0
• Anyone can contribute
• Active contributors become committers through
community vote.
• Apache Derby community is
> growing at fast pace
> a very active one
> a great place to learn more about database internals
Sun Confidential: Internal Only
36
Current GA 10.3.1 Release Features
• Security improvements
> DBA Powers
> Secure Server by Default
> SSL / TLS between client and server
•
•
•
•
•
Language Based Ordering (Collation)
Alter Table Enhancements (drop/rename column)
More Performance Improvements
BLOB / CLOB Enhancements
More info at:
> http://wiki.apache.org/db-derby/DerbyTenThreeRelease
Sun Confidential: Internal Only
37
Working on Next Release (10.4)
• SQL Roles
• System privileges
> Restrict who can shutdown engines and create
databases
• SQL OLAP functionality
> e.g., ROW_NUMBER()
•
•
•
•
Unique constraints on nullable columns
Basic replication for high availability
VTI (Table Functions)
JMX management interface
Sun Confidential: Internal Only
38
Participate!
• http://db.apache.org/derby
> Download, read docs
• JIRA http://issues.apache.org/jira/browse/DERBY
> Report bugs, submit patches
• [email protected]
> Discuss experience, get help, give feedback
• [email protected]
> Discuss developer issues
Sun Confidential: Internal Only
39
Derby Integration
• ActiveMQ
• IBM DB2 Everyplace
• AntHill Pro
• IBM DB2 JDBC
Universal Driver
• Apache Cocoon
• Red Hat Application
Server
• Roller 2.0
• Apache Geronimo
• IBM WebSphere App
Server
• Apache JDO
• ISQL-Viewer
• Apache Xalan
• Java DB
• Daffodil Replicator
• JBoss
• Sun Java Portal
Server
• Data Direct SequeLink
• JPOX
• Sun Java Studio
• DB Visual Architect
• Jython
• Sun Java EE
• Drone IRC Bot
• Kodo 3.3.3
• Sun Service Registry
• Eclipse
• Maven
• SUSE Linux 9.3
• Glassfish
• Netbeans
• Zend core for IBM
• Hibernate
• Zimbra
• Tomcat
• IBM Cloudscape
Sun Confidential: Internal Only
• Sequoia (C-JDBC)
• SQuirreL SQL
• Sun Java ES
40
References
• TaxDemo:
> http://developers.sun.com/javadb/overview/product_tour/readm
• Netbeans Demo:
> http://www.netbeans.org/kb/55/derby-demo.html
Sun Confidential: Internal Only
41
Related documents