Derby Database Brief Introduction and use method __ Database

Source: Internet
Author: User
Tags documentation log log
introduction of Derby databaseApache Derby is a 100% Java-written memory database that belongs to an open source project in Apache. And it is an easy to manage relational database management system that can be delivered with the characteristics of some commercial products.
Apache Derby is a platform-independent database engine that provides services externally in the form of a Java class library. Unlike other databases that are difficult to deploy, the Derby database is small in size and simple to install, simply by copying its *.jar files to the system and adding the *.jar file to the user's project.
two operating modes of Derby database1) inline mode. The Derby database shares the same JVM as the application, which is typically the responsibility of the application to start and stop, except for the application that starts it
Other applications outside the order are not visible, that is, other applications cannot access it;
2) network mode. The Derby database has a single JVM that runs as a stand-alone process on the server. In this mode, multiple applications are allowed
Program to access the same derby database.
Three, there are many technical aspects to distinguish Derby and other database systemsDerby is easy to manage. The Derby system does not require any administrative intervention when embedded in the client application.
Derby is embeddable. Applications can embed database management system (DB Management System, DBMS) engine into application
program process, thereby eliminating the need to manage separate database processes or services. You can run Derby as a separate process through a network server (network server) schema or a server schema of your choice.

Derby is a pure Java class library: This is important for Java developers because they are trying to maintain the benefits of Java technology,

such as platform independence, ease of configuration, and ease of installation. Derby does not require proprietary Java virtual machines (Java dummy Machine, JVM). Because it's written entirely in the Java language, so
It adapts to all qualified JVMs.
The Derbydbms engine is lightweight. The class file size is approximately 2MB and uses only the 4MB Java heap.
Derby supports the use of Java to write stored procedures and functions that can run on any layer of the application. Derby No
A dedicated stored procedure language that uses JDBC.
Four, Derby database advantages and Disadvantages 1, Derby positioning is a small database, especially embedded. Supported databases less than 50GB, for small Web sites, transaction-less complex applications
, the use of it is still very good. Other large desktop applications can also use it to save configuration and other data that can be done in relation to file formats,
Because it's all about accessing the database.
2, Functions: Derby support Standard SQL92, SQL1999, SQL2003, support temporary tables, indexes, triggers, views, stored procedures,
Foreign keys, constraints, parallelism, transactions, encryption, and security. As long as you have JDK (>=1.3), you can run Derby.
3, Security: Derby security is also done in place, including user authentication and encryption decryption.
4, Performance: Derby performance is also good. When inserting 1 million records, the CPU occupancy rate has been lower than 40%, averaging each
The record takes less than 0.3 milliseconds. This is more than sufficient to meet desktop applications. But compared to Oracle, MYSQL and other professional database sex

Can be low

v. Methods of Use 1. Install Derby database only need to download Derby zip or tar package from Derby official website, unzip it. Here, for example, the Db-derby-10.4.1.3-bin version of the solution
After the press get the following directory:
1 The Bin directory, contains a number of tool scripts and device environment scripts;
2 demo directory, including some examples of programs;
3 Docs directory, containing the derby documentation;
4 Javadoc directory containing the API documentation for Derby;
5 lib directory, containing the Derby database jar file;
6 test directory, some of Derby's testing jar packages;

2, using IJ script 1 to run the inline mode of the Derby database
Locate the bin directory on the command line, use the IJ tool with input ij (or start the IJ tool after clicking Ij.bat). Then create the database and create a connection to the database by using the following command:
Connect ' jdbc:derby:firstdb;create=true ';
(The Connect command allows you to create a connection to a specified database and specify which database to create with a JDBC URL.) The IJ command is case-insensitive. The Jdbc:derby in the parameter is the driver protocol for the Derby database; Firstdb is the database name, and the database will be created in the directory under your current command line, because no path is specified; create=true means that if the database does not exist, the database is created; Is the terminator of the IJ command. When the database is created successfully, Derby creates a directory that is consistent with the database (here is FIRSTDB) in the directory under your current command line, which holds the database files. )
After you connect to the database, you can start executing the SQL script, such as creating a table:
CREATE TABLE firsttable (ID int primary key, name varchar (20));
Then insert the record:
INSERT into firsttable values (1, ' hotpepper ');
You can also execute a query:
SELECT * from Firsttable;
You can also execute SQL files by using the Run command:
Run ' e:/derby/demo/toursdb_schema.sql ';
Exit the IJ tool with the last exit;
You can find a derby.log log file in the directory where you are currently on your command line, and information about the database that Derby logs to startup and shutdown.

2 The Derby database running network mode
In this mode, you need to use two console windows, one to start the Derby database server, and the other to access the Derby database client. You need to enter the bin directory at the command line, run Startnetworkserver.bat to start the database server, and the other port is similar to the Derby database running inline mode, except that the commands for the connection are different:

Connect ' jdbc:derby://localhost:1527/g:/csesi_data/csesi;create=true ';

(where localhost:1527 is the local and port number, and the following is a database of G disk, or it can be online)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.