Embedded relationship database: derby

tags: Knowledge

Apache Derby

Derby Introduction

Apache Derby is written in JavaOpen source embedded relationship databaseIt is very small. The core part of Derby.jar is only 2m, so it can be used as a separate database service or embedded in the application.

The main feature of Derby is:

  • The program is small, the total size of the basic engine and the embedded JDBC driver is about 2MB
  • Based on Java, JDBC, and SQL standards
  • Provide an embedded JDBC driver, which can be embedded in Java -based applications
  • Support client, server mode
  • Installation, deployment, simple use

Derby download

Apache Derby's official website providesDownload page.
Select 10.14.2.0 here

After clicking the version connection, click to download DB-DERBY-10.14.2.0-BIN.ZIP file

After the download is complete

  • The BIN directory contains the script of environmental settings, service management, and commonly used tools
  • Demo directory contains several examples;
  • The DOCS directory contains the official Derby document;
  • Javadoc directory contains API documents;
  • The lib directory contains all the .jar files of Derby;
  • The TEST directory contains the derby regression test.

Next, you need to set the environment variable of Derby, set the derby_home to the directory after decompression, and add the derby_home/bin to the PATH environment variable

Then enter IJ in the CMD window

Derby deployment mode

Apache Derby supports two deployment methods: embedded (Embedded) or client/server mode (Client/Server)

Embedded

Derby runs in the JVM of the Java application, and the Java application drives the database through Embedded Derby JDBC. At this time, Derby belongs to part of the Java application, and the Java application starts and closed. Users cannot perceive the existence of Derby, and usually do not need to be configured and manage.

Client/server mode

Derby runs in the server JVM, and multiple applications are connected to the Derby database through the network. At this time, Derby Network Server is responsible for managing connection requests from the client. The client is connected to the server through the Derby Network Client JDBC driver.

Derby basic operation

IJ is an interactive SQL script tool for operating the Derby database.

Create a database

Create a database through the IJ tool

ij> connect 'jdbc:derby:xxoo;create=true';

Create = true in the connection indicates a new database, name XXOO

Connect to the database

ij> connect 'jdbc:derby:xxoo';

Execute SQL statement

ij> create table test(id int primary key, name varchar(50));
Have been inserted/renew/delete  0  Row 
ij> insert into test values(1, 'apple'),(2, 'banana');
 Have been inserted/renew/delete  2  Row 
ij> select * from test;
ID         |NAME
--------------------------------------------------------------
1          |apple
2          |banana
 chosen  2  Row

Run SQL script

ij> run 'myfile.sql';

The run command will print and execute the content in the script file.

Disposter database connection

ij> disconnect;
ij> 

Exit IJ

ij> exit;

If you want to exit the IJ tool, use the exit command;For embedded mode, the command will turn off the database at the same time.

Derby embedded

Add Maven dependencies

<dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derby</artifactId>
    <version>10.14.2.0</version>
</dependency>

Use JDBC steps

1. Register drive

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

2. Establish connection

Connection conn = DriverManager.getConnection("jdbc:derby:xxoo;create=true");

Then use JDBC to operate

JDBC introduction and use

Intelligent Recommendation

Derby embedded

First, the introduction of Derby database 1. Overview of Derby's development history and characteristics Derby is an open source, 100% relational database developed by Java. With the popularity of the...

If you want an embedded database (H2, HSQL or Derby), please put it on the classpath..

The above error occurred during the SpringCloud project. Analysis: The error is missing the four elements of the data link, possible reasons, really did not write four elements, write wrong, The analy...

If you want an embedded database (H2, HSQL or Derby), please put it on the classpath

When using IDEA to integrate the spring cloud project, in order to test load balancing and whether the provider and the user can communicate successfully, a provider producer1 is created first, and my...

Derby database embedded mode set password trick mode

The derby database sets the password trick. The first thing to use is the visualization tool that comes with NetBeans. Create a database   The database name is: derbyTest. Username: test. Passwor...

If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.

In the maven pom files modified in the configuration file location, error on startup: Solution: Modify the startup classSpringBootApplicationNotes are:...

More Recommendation

Solve the error: If you want an embedded database (H2, HSQL or Derby)

Solve the error Right-click resources, select MarkDirectorys as, and select resource root. Just restart it!...

Consider the following: If you want an embedded database (H2, HSQL or Derby)

wrong reason The mybatis-spring-boot-starter is introduced in the pom. Spring boot will load the org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration class by default. The DataSourc...

If you want an embedded database (H2, HSQL or Derby), please put it on the clas

The database file is not configured, such as the yml file in spring-boot....

error:If you want an embedded database (H2, HSQL or Derby)

error code wrong reason: The automated configuration of the data source is triggered, but the current project does not require a data source. The root cause is the API dependencies provided by the dep...

Error: Consider the Following: If you want an embedded database (H2, HSQL or DERBY)

1. Problem description: Error reporting the SpringBoot project time, the problem description is as follows: 2. Reason: Introduced mybatis-spring-boot-starter coordinates in POM, Spring Boot will load ...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top