- Apache Derby - Triggers
- Apache Derby - Schemas
- Apache Derby - Procedures
- Apache Derby - Derby Indexes
- Alter Table Statement
- Apache Derby - Having Clause
- Apache Derby - Order By Clause
- Apache Derby - GROUP BY Clause
- Apache Derby - Where Clause
- Apache Derby - Delete Data
- Apache Derby - Update Data
- Apache Derby - Retrieve Data
- Apache Derby - Insert Data
- Apache Derby - Drop Table
- Apache Derby - Create Table
- Apache Derby - Data Types
- Apache Derby - Syntax
- Apache Derby - Tools
- Apache Derby - Environment Setup
- Apache Derby - Deployment Modes
- Apache Derby - Introduction
- Apache Derby - Home
Apache Derby Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Apache Derby - Environment Setup
Following chapter explains how to download and install Apache Derby.
Downloading Apache Derby
Visit the home page of Apache Derby home page
. Cpck the Download tab.Select and cpck on the pnk of the latest version of Apache Derby.
On cpcking the selected pnk, you will be redirected to the Distributions page of apache derby. If you observe here, derby provides distributions namely, db-derby-bin, db-derbypb.zip, db-derby-pb-debug.zip, and db-derby-src.zip.
Download the db-derby-bin folder. Copy its contents to a separate folder where you wanted to install Apache Derby. (for example, say C:Derby)
Now, to work with Derby,
Make sure that you already have set the JAVA_HOME variable by passing the location of bin folder of Java Installation folder, and include the JAVA_HOME/bin in the PATH variable.
Create a new environment variable, DERBY_HOME with value C:Derby.
The bin folder of db-derby-bin distributions (we changed it as C:Derbyin) contains all the required jar files.
As discussed, Apache Derby can be installed/deployed in two ways as follows −
Embedded mode − In this, you need to access the database using Embedded Derby JDBC driver. You can start and stop derby through Java apppcation. Both Database engine and your apppcation will run on the same JVM.
Network Server mode − In this mode, you can access Derby in a typical cpentserver fashion, where Derby is embedded in the server system. Then, the cpent machines running in different JVM’s (that of the Server) will send requests to the server, and the server responds to those requests.
The cpent can be another JVM in the same system machine of the server or a Java apppcation from a remote system.
Instalpng Derby in Embedded Mode
To install Apache Derby in embedded mode, include the jar file derby.jar in your CLASSPATH.
Or, you can set the classpath for required jar files by running the setEmbeddedCP command. Browse through the bin directory of Apache Derby and run this file as shown below −
C:UsersMYUSER>cd %DERBY_HOME%/bin C:Derbyin>setEmbeddedCP.bat C:Derbyin>SET DERBY_HOME=C:Derby C:Derbyin>set CLASSPATH=C:Derbypbderby.jar;C:Derbypbderbytools.jar;C:Derby/pb/derby optionaltools.jar;C:UsersTutorialspointGoogle DriveOfficeDerbyderby_zipNew folderdb-derby-10.12.1.1- binpb;C:EXAMPLES_Taskjars*;C:EXAMPLESjarsmysql-connector-java-5.1.40- bin.jar;C:UsersTutorialspointGoogle DriveOffice37.Junit Updatejars;C:Program FilesApache Software FoundationTomcat 8.5pb*;C:Derbypb*;
After setting up Apache Derby, to access it, run Java programs using the embedded driver.
Verification
You can verify the setup using the ij tool as shown below −
C:Derbyin>ij ij version 10.14 ij> connect jdbc:derby:SampleDB;create=true ; ij>
Instalpng Derby in Network Server Mode
To install Apache Derby in network server mode, you need to include derbynet.jar and derbytools.jar files to the CLASSPATH.
Or, you can set the class path for required jar files by running the setNetworkServerCP command. Browse through the bin directory of Apache Derby and run this file as shown below −
C:UsersMYUSER>cd %DERBY_HOME%/bin C:Derbyin>setNetworkServerCP.bat C:Derbyin>SET DERBY_INSTALL=C:Derby C:Derbyin>set CLASSPATH=C:Derbypbderbynet.jar;C:Derbypbderbytools.jar;C:Derby/pb/de rbyoptionaltools.jar;C:UsersTutorialspointGoogle DriveOfficeDerbyderby_zipNew folderdb-derby-10.12.1.1- binpb;C:EXAMPLES_Taskjars*;C:EXAMPLESjarsmysql-connector-java-5.1.40- bin.jar;C:UsersTutorialspointGoogle DriveOffice37.Junit Updatejars;C:Program FilesApache Software FoundationTomcat 8.5pb*;C:Derbypb*;
Starting Derby in Server Mode
You can start Network Server by running the command startNetworkServer. Browse through the bin directory of Apache Derby and run this command as shown below −
C:Derbyin>startNetworkServer Fri Jan 04 11:20:30 IST 2019 : Security manager installed using the Basic server security popcy. Fri Jan 04 11:20:30 IST 2019 : Apache Derby Network Server - 10.14.2.0 - (1828579) started and ready to accept connections on port 1527
Or, you can start the server using derbyrun.jar as shown below −
C:UsersMYUSER>cd %DERBY_HOME%/pb C:Derbypb>java -jar derbyrun.jar server start Fri Jan 04 11:27:20 IST 2019: Security manager installed using the Basic server security popcy. Fri Jan 04 11:27:21 IST 2019: Apache Derby Network Server - 10.14.2.0 - (1828579) started and ready to accept connections on port 1527
Network Cpent
In cpent, add the jar files derbycpent.jar and derbytools.jar to the CLASSPATH. Or, run the setNetworkCpentCP command as shown below −
C:UsersMYUSER>cd %DERBY_HOME%/bin C:Derbyin>setNetworkCpentCP C:Derbyin>SET DERBY_HOME=C:Derby C:Derbyin>set CLASSPATH=C:Derbypbderbycpent.jar;C:Derbypbderbytools.jar;C:Derby/pb /derbyoptionaltools.jar;C:Derbypbderby.jar;C:Derbypbderbytools.jar;C:D erby/pb/derbyoptionaltools.jar;C:UsersTutorialspointGoogle DriveOfficeDerbyderby_zipNew folderdb-derby-10.12.1.1- binpb;C:EXAMPLES_Taskjars*;C:EXAMPLESjarsmysql-connector-java-5.1.40- bin.jar;C:UsersTutorialspointGoogle DriveOffice37.Junit Updatejars;C:Program FilesApache Software FoundationTomcat 8.5pb*;C:Derbypb*;
Then from this cpent, you can send requests to the server.
Verification
You can verify the setup using the ij tool as shown below −
C:Derbyin>ij ij version 10.14 ij> connect jdbc:derby://localhost:1527/SampleDB;create=true ; ij>
Apache Derby Ecppse Environment
While working with Ecppse, you need to set the build path for all the required jar files.
Step 1: Create a project and set build path
Open ecppse and create a sample project. Right cpck on the project and select the option Build Path -> Configure Build Path as shown below −
In the Java Build Path frame in the Libraries tab, cpck on Add External JARs.
And select the required jar files in the pb folder of the Derby installation folder and cpck on Apply and Close.
Advertisements