### Start Network Server via NetworkServerControl main class Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Alternative way to start the Network Server by invoking its main class from the command line. ```bash java -cp $DERBY_HOME/lib/derbynet.jar org.apache.derby.drda.NetworkServerControl start ``` -------------------------------- ### Start Network Server with derbyrun.jar on Windows Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Starts the Derby Network Server from the command line. The server must be running before connecting with a client driver. ```batch java -jar %DERBY_HOME%\lib\derbyrun.jar server start ``` -------------------------------- ### Start Network Server with derbyrun.jar on UNIX Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Starts the Derby Network Server from the command line. The server must be running before connecting with a client driver. ```bash java -jar $DERBY_HOME/lib/derbyrun.jar server start ``` -------------------------------- ### Run the demo with ij tool Source: https://github.com/apache/derby/blob/trunk/java/demo/vtis/README.html Executes the demo SQL script using Derby's interactive ij tool from the demo/programs/vtis directory. A successful run produces many pages of SQL commands and query results. ```bash java org.apache.derby.tools.ij demoFileVtis.sql ``` -------------------------------- ### Start SimpleApp in Derby client mode Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Runs SimpleApp with the 'derbyclient' argument, which tells the program to use the Derby client driver instead of its default embedded driver. Requires the Derby Network Server to be started in a different command window first. ```bash java SimpleApp derbyclient ``` -------------------------------- ### Start Network Server with compiled classes for remote testing Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Use this command on the remote host when running Network Server from compiled classes. It requires a copied derby_tests.policy file, a classpath with derbynet.jar and derbyTesting.jar, and derby.jar available. The derby.system.home is set to the directory where Network Server is started, and the policy file is in that directory. ```bash java -Djava.security.manager -Djava.security.policy=copied_derby_tests.policy -DderbyTesting.codeclasses=file:/derby/classes/ -DderbyTesting.codedir=/derby/classes -DderbyTesting.serverhost=localhost -DderbyTesting.clienthost=clientIPaddress -DderbyTesting.codejar=file://unused/ org.apache.derby.drda.NetworkServerControl -h 0.0.0.0 start ``` -------------------------------- ### Run SimpleNetworkServerSample Source: https://github.com/apache/derby/blob/trunk/java/demo/nserverdemo/simpleserversample.html Executes the server sample program from the nserverdemo directory. The program starts the Derby Network Server, creates the NSSimpleDB database, and waits for client connections. ```bash java SimpleNetworkServerSample ``` -------------------------------- ### Start Network Server with jars for remote testing Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Use this command on the remote host when running Network Server from jars. It requires a copied derby_tests.policy file, a classpath with derbynet.jar and derbyTesting.jar, and derby.jar available. The derby.system.home points to the directory with derby.properties, derby.log, and databases, and the policy file is in that directory. ```bash java -Dderby.system.home=/home/derbytst/ns -Djava.security.manager -Djava.security.policy=/home/derbytst/ns/copied_derby_tests.policy -DderbyTesting.clienthost=clientIPaddress -DderbyTesting.codejar=file:/derby/tstbld/ -DderbyTesting.codedir=/derby/tstbld -DderbyTesting.serverhost=localhost -DderbyTesting.codeclasses=file://unused/ org.apache.derby.drda.NetworkServerControl -h 0.0.0.0 start ``` -------------------------------- ### Network Server startup console output Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Expected console output when the Network Server starts successfully. Indicates the server is ready to accept connections on port 1527. ```text Security manager installed using the Basic server security policy. Apache Derby Network Server - - () started and ready to accept connections on port 1527 at ``` -------------------------------- ### Set CLASSPATH for the demo (Windows) Source: https://github.com/apache/derby/blob/trunk/java/demo/vtis/README.html Sets the CLASSPATH to include the current directory (location of demoFileVtis.sql), Derby's embedded driver library (derby.jar), and Derby's tool library (derbytools.jar). Run from the %DERBY_HOME%\demo\programs\vtis directory. ```batch set CLASSPATH=.;%DERBY_HOME%\lib\derby.jar;%DERBY_HOME%\lib\derbytools.jar ``` -------------------------------- ### Set CLASSPATH for the demo (UNIX ksh/bash) Source: https://github.com/apache/derby/blob/trunk/java/demo/vtis/README.html Sets the CLASSPATH to include the current directory (location of demoFileVtis.sql), Derby's embedded driver library (derby.jar), and Derby's tool library (derbytools.jar). Run from the $DERBY_HOME/demo/programs/vtis directory. ```bash export CLASSPATH=.:${DERBY_HOME}/lib/derby.jar:${DERBY_HOME}/lib/derbytools.jar ``` -------------------------------- ### Expected output from NsSample demo program Source: https://github.com/apache/derby/blob/trunk/java/demo/nserverdemo/nserverdemo.html This is the output you should see when the demo runs successfully. It shows the JDBC driver used, the Network Server starting on port 1621, sample work threads performing insert/update/delete/select operations, and the server shutdown. ```text Using JDBC driver: org.apache.derby.jdbc.ClientDriver Derby Network Server created Apache Derby Network Server started and ready to accept connections on port 1621 [NsSample] Derby Network Server started. [NsSample] Sample Derby Network Server program demo starting. Please wait ..................... [NsSampleWork] Begin creating table - SAMPLETBL and necessary indexes. [NsSampleClientThread] Thread id - 2; started. [NsSampleWork] Thread id - 2; requests database connection, dbUrl =jdbc:derby://localhost:1621/NSSampledb;create=true; [NsSampleClientThread] Thread id - 1; started. [NsSampleWork] Thread id - 1; requests database connection, dbUrl =jdbc:derby:NSSampledb; [NsSampleWork] Thread id - 1; inserted 1 row. [NsSampleWork] Thread id - 1; inserted 1 row. [NsSampleWork] Thread id - 1; deleted 1 row with t_key = 9372 [NsSampleWork] Thread id - 1 selected 1 row [920,Derby50 ,951.7808,9216] [NsSampleWork] Thread id - 1 selected 1 row [920,Derby50 ,951.7808,9216] [NsSampleWork] Thread id - 1; inserted 1 row. [NsSampleWork] Thread id - 1 selected 1 row [920,Derby50 ,951.7808,9216] [NsSampleWork] Thread id - 1; deleted 1 row with t_key = 9216 [NsSampleWork] Thread id - 1 selected 1 row [824,Derby26 ,8.802546E22,9155] [NsSampleWork] Thread id - 1; updated 1 row with t_key = 9155 [NsSampleWork] Thread id - 1; closed connection to the database. [NsSampleClientThread] Thread id - 1; finished all tasks. [NsSampleWork] Thread id - 2; updated 0 row with t_key = 9372 [NsSampleWork] Thread id - 2; updated 1 row with t_key = 9155 [NsSampleWork] Thread id - 2 selected 1 row [56,Derby26 ,8.802546E22,9155] [NsSampleWork] Thread id - 2; inserted 1 row. [NsSampleWork] Thread id - 2; updated 1 row with t_key = 9155 [NsSampleWork] Thread id - 2; deleted 1 row with t_key = 9155 [NsSampleWork] Thread id - 2 selected 1 row [785,Derby2 ,0.30170244,8280] [NsSampleWork] Thread id - 2 selected 1 row [785,Derby2 ,0.30170244,8280] [NsSampleWork] Thread id - 2; updated 1 row with t_key = 8280 [NsSampleWork] Thread id - 2 selected 1 row [59,Derby2 ,0.30170244,8280] [NsSampleWork] Thread id - 2; closed connection to the database. [NsSampleClientThread] Thread id - 2; finished all tasks. [NsSample] Shutting down network server. Apache Derby Network Server - shutdown [NsSample] End of Network server demo. ``` -------------------------------- ### RunSuite upgrade with derbyTesting.jar.path Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Example command line for running the upgrade suite when Derby 10.1 jars reside in /opt/testing/derby/10.1. After changing the property, remove the generated Upgrade_10_1_10_2.properties file and run 'ant all' to regenerate it. ```bash java -Djvmflags=-DderbyTesting.jar.path=/opt/testing/derby org.apache.derbyTesting.functionTests.harness.RunSuite upgrade ``` -------------------------------- ### query.list file format example Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/optimizer/README.txt Format for the query.list file: each line is = with no semicolon at the end. This example defines a query named Query1 that selects from views sum_view_8a, max_view_8b, and min_view_8b. ```text Query1=select col1, max_view_8bc1 from sum_view_8a right join max_view_8b on col1=max_view_8bc1 where col1 <100 union all select col1, min_view_8bc1 from sum_view_8a right join min_view_8b on col1=min_view_8bc1 where col1 <100 ``` -------------------------------- ### Successful test run output Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Example output from a successful test run in a DOS environment. It shows the test name, properties, start/end markers, and the master file name. Cleanup occurs unless -Dkeepfiles=true is used. ```text c:> derbyTesting.functionTests.harness.RunTest lang/supersimple.sql C:\derby\run2 supersimple -- listing properties -- derby.locks.deadlockTimeout=3 derby.locks.waitTimeout=3 *** Start: supersimple jdk1.4.2_03 2004-11-10 16:51:02 *** The test should be running... MasterFileName = master/supersimple.out *** End: supersimple jdk1.4.2_03 2004-11-10 16:51:25 *** ``` -------------------------------- ### Binary column example Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tools/org/apache/derby/jdbc/package.html Provides an example of how getBinaryStream(), getAsciiStream(), getCharacterStream(), and getString() behave for a binary column set with a Java byte array containing four bytes: {0x34, 0x87, 0xc2, 0x1f}. ```APIDOC ## Binary column example ### Description If a binary column has been set with the Java byte array containing four bytes, byte[] data = {0x34, 0x87, 0xc2, 0x1f}, then: - getBinaryStream() returns a java.io.InputStream containing four bytes - 0x34, 0x87, 0xc2, 0x1f - getAsciiStream() returns a java.io.InputStream containing four bytes - 0x34, 0x87, 0xc2, 0x1f [same as getBinaryStream()] - getCharacterStream() returns a java.io.Reader containing two characters - 0x3487, 0xc21f - getString() returns a String with eight characters "3487c21f" ``` -------------------------------- ### Run MailJdbc in NetworkServer mode Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/mailjdbc/README.txt Starts the mail client scenario test using the NetworkServer driver. The network server must be started manually from the same directory as the client, otherwise client threads attempting to run compress will fail to find the database. ```bash java org.apache.derbyTesting.system.mailjdbc.MailJdbc NetworkServer ``` -------------------------------- ### Set DERBY_HOME environment variable (Windows) Source: https://github.com/apache/derby/blob/trunk/java/demo/vtis/README.html Sets the DERBY_HOME environment variable to the Derby installation location on Windows. Required for referencing Derby resources later in the demo setup, though not strictly required to run the demo. ```batch set DERBY_HOME=c:\programs\derby\db-derby-10.x.y.z-bin ``` -------------------------------- ### Run a single Derby test with network server and derbyclient Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Runs the supersimple test using the network server with the derbyclient driver by adding -Dframework=DerbyNetClient. The harness starts a network server on port 1527 or connects to a running one, runs the test, and stops the server afterward. ```shell java -Dframework=DerbyNetClient org.apache.derbyTesting.functionTests.harness.RunTest lang/supersimple.sql ``` -------------------------------- ### Set DERBY_HOME environment variable (UNIX ksh/bash) Source: https://github.com/apache/derby/blob/trunk/java/demo/vtis/README.html Sets the DERBY_HOME environment variable to the Derby installation location. Required for referencing Derby resources later in the demo setup, though not strictly required to run the demo. ```bash export DERBY_HOME=/home/user/derby/db-derby-10.x.y.z-bin ``` -------------------------------- ### Run a single test with system properties Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Use the test harness property -DtestSpecialProps to pass system-level properties to the test harness. This example appends extra information to the log by setting derby.infolog.append=true. The test runs in the current directory, or in a subdirectory 'DerbyNetClient' when using the network server framework. ```bash java -Dframework=DerbyNetClient -DtestSpecialProps=derby.infolog.append=true org.apache.derbyTesting.functionTests.harness.RunTest lang/supersimple.sql ``` -------------------------------- ### Test failure output Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Example output when a test fails. It shows the diff, creates a .fail file, does not create a .pass file, and does not clean up any files upon completion. ```text c:> derbyTesting.functionTests.harness.RunTest lang/supersimple.sql C:\derby\run2 supersimple -- listing properties -- derby.locks.deadlockTimeout=3 derby.locks.waitTimeout=3 *** Start: supersimple jdk1.4.2_03 2004-11-10 16:54:39 *** The test should be running... MasterFileName = master/supersimple.out 10 del < 10 10a10 > 1 Test Failed. *** End: supersimple jdk1.4.2_03 2004-11-10 16:55:02 *** ``` -------------------------------- ### Check Java version with java -version Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Verify that Java 9 is installed before building Derby. Run this command from the root of the Derby source distribution. ```shell java -version ``` -------------------------------- ### Clean build artifacts with ant clobber Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Deletes all build artifacts. Use this target to start a clean build. ```shell ant -quiet clobber ``` -------------------------------- ### Run mvn clean install with GPG passphrase Source: https://github.com/apache/derby/blob/trunk/maven2/README.txt Generates artifacts, signs them with GnuPG, and installs them in the local repository. The passphrase is provided via -Dgpg.passphrase; do not put it in the deployed POM. ```bash mvn -Dgpg.passphrase="my secret passphrase" clean install ``` -------------------------------- ### Run a Derby test suite with verbose output Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Runs the derbylang suite using the RunSuite harness with verbose output enabled. Each suite run should be started in a clean directory; the test output directory is not emptied before testing, but individual test and result files are cleaned and overwritten. ```shell java -Dverbose=true org.apache.derbyTesting.functionTests.harness.RunSuite derbylang ``` -------------------------------- ### Run MailJdbc in embedded mode with samedb Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/mailjdbc/README.txt Runs the test using the same database as a previous run. Requires the same setup as the standard embedded run. ```bash java org.apache.derbyTesting.system.mailjdbc.MailJdbc embedded samedb ``` -------------------------------- ### Run jdbc40 suite with embedded and DerbyNetClient frameworks Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/jdbc4/README.html Run the jdbc40 test suite first under the embedded framework, then under the DerbyNetClient framework. Requires JAVA_HOME pointing at a jdk1.6 installation. After each run, check the test results to ensure success. ```shell java org.apache.derbyTesting.functionTests.harness.RunSuite jdbc40 # make sure the above test run succeeded java -Dframework=DerbyNetClient org.apache.derbyTesting.functionTests.harness.RunSuite jdbc40 # make sure the above test run succeeded ``` -------------------------------- ### Run a test with specific encoding using -DderbyTesting.encoding Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Forces a specific test to run with a given encoding, currently only supported with jdk15. Example runs lobStreams.java with UTF-16 encoding. ```shell java -DderbyTesting.encoding=UTF-16 org.apache.derbyTesting.functionTests.harness.RunTest jdbcapi/lobStreams.java ``` -------------------------------- ### Run MailJdbc in NetworkServer mode with samedb Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/mailjdbc/README.txt Runs the test using the same database as a previous run in NetworkServer mode. The network server must be started manually from the same directory as the client, otherwise client threads attempting to run compress will fail to find the database. ```bash java org.apache.derbyTesting.system.mailjdbc.MailJdbc NetworkServer samedb ``` -------------------------------- ### Run MailJdbc in embedded mode Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/mailjdbc/README.txt Starts the mail client scenario test using the embedded Derby driver. Requires Java, Derby jars including derbyTesting.jar in the classpath, and the derby.properties file copied from org/apache/derbyTesting/system/mailjdbc. ```bash java org.apache.derbyTesting.system.mailjdbc.MailJdbc embedded ``` -------------------------------- ### Execute NsSample with optional driverType argument Source: https://github.com/apache/derby/blob/trunk/java/demo/nserverdemo/nserverdemo.html Run the Network Server demo from the DERBY_INSTALL\demo\programs directory. The driverType argument is optional; the default is derbyClient. Successful execution creates the NSSampledb database directory and derby.log file. ```bash java nserverdemo.NsSample [driverType] ``` -------------------------------- ### Run SimpleApp application Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Executes the SimpleApp application from the demo/programs/simple directory. The default framework is embedded, so no extra arguments are needed. ```bash java SimpleApp ``` -------------------------------- ### Run Derby Sysinfo utility with client and SimpleApp.class arguments Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Optional step to test the classpath. The 'client' argument indicates a client environment, and 'SimpleApp.class' tests for the presence of the SimpleApp class. Run all on one line. ```bash java org.apache.derby.tools.sysinfo -cp client SimpleApp.class ``` -------------------------------- ### Verify PGP signatures with gpg --import Source: https://github.com/apache/derby/blob/trunk/RELEASE-NOTES.html Verify the PGP signature using GPG. Import the KEYS file, then verify the .asc signature file with --verify. ```shell % gpg --import KEYS % gpg --verify db-derby-X.Y.tar.gz.asc ``` -------------------------------- ### Run SimpleNetworkClientSample with driverType argument Source: https://github.com/apache/derby/blob/trunk/java/demo/nserverdemo/simpleserversample.html Executes the client sample from the nserverdemo directory. The optional driverType argument accepts derbyClient (the default). Requires derbyclient.jar and the current directory in the CLASSPATH. Successful output includes connection messages and row counts from sys.systables. ```bash java SimpleNetworkClientSample [driverType] ``` -------------------------------- ### Check out entire Derby development trunk via SVN Source: https://github.com/apache/derby/blob/trunk/plugins/eclipse/Readme.txt Use this command to check out the entire Derby development trunk, which includes the source for both the UI and Help plug-ins. This is the first step in creating the plug-in projects. ```bash svn checkout https://svn.apache.org/repos/asf/db/derby/code/trunk/ ``` -------------------------------- ### RunTest with framework property Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Specifies the framework to run with, e.g., DerbyNetClient. The test harness class NetServer uses the actual configuration for the individual frameworks. ```bash java -Dframework=DerbyNetClient org.apache.derbyTesting.functionTests.harness.RunTest lang/supersimple.sql ``` -------------------------------- ### Verify Derby build with sysinfo Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Run the sysinfo command to verify that the jars built correctly. This program prints out the Derby build information. ```shell java -jar jars/sane/derbyrun.jar sysinfo ``` -------------------------------- ### Run tests on client machine with hostName property Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Run the test suite on the client machine, specifying the remote host via -DhostName. The test harness automatically sets startServer=false when hostName is not null and not localhost. Replace favorite.remotehost.com with the remote host name or IP address. ```bash java -DhostName=favorite.remotehost.com org.apache.derbyTesting.functionTests.harness.RunSuite derbynetclientmats ``` -------------------------------- ### Test CLASSPATH with org.apache.derby.tools.sysinfo Source: https://github.com/apache/derby/blob/trunk/java/demo/nserverdemo/nserverdemo.html Run this command to verify that derbynet.jar, derbyclient.jar, and derby.jar are in the CLASSPATH. It displays the Derby jar files and their versions. ```bash java org.apache.derby.tools.sysinfo ``` -------------------------------- ### Run Optimizer Test with -reset or -qlist Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/optimizer/README.txt Invoke the optimizer test from the command line. Use -reset to reset the database and begin a run, -qlist to run only queries from the query.list file, and -verbose to print all queries being run. No arguments runs all default test queries. ```bash java org.apache.derbyTesting.system.optimizer.RunOptimizerTest -reset|-qlist ``` -------------------------------- ### Simple Derby build sequence Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Run these three Ant targets in order to perform a simple build of Derby. ```shell ant -quiet clobber ant -quiet buildsource ant -quiet buildjars ``` -------------------------------- ### Expected output from SimpleNetworkServerSample Source: https://github.com/apache/derby/blob/trunk/java/demo/nserverdemo/simpleserversample.html Shows the expected output when the server program runs successfully. It includes a note that ij can connect while the server is busy, and the program waits for the user to press Enter to stop the server. ```text Starting Network Server Testing if Network Server is up and running! Derby Network Server now running Got an embedded connection. Testing embedded connection by executing a sample query number of rows in sys.systables = 23 While my app is busy with embedded work, ij might connect like this: $ java -Dij.user=me -Dij.password=pw -Dij.protocol=jdbc:derby://localhost:1527/ org.apache.derby.tools.ij ij> connect 'NSSimpleDB'; Clients can continue to connect: Press [Enter] to stop Server ``` -------------------------------- ### RunSuite command for derbylang suite Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Sample output from running the RunSuite harness for the derbylang test suite. The command creates a subdirectory named after the suite and generates summary files. Note that RunSuite does not empty the top-level directory, so run each suite in a clean directory to avoid stale results. The output does not show pass/fail status; check the report file for statistics. ```text c:> $ java org.apache.derbyTesting.functionTests.harness.RunSuite derbylang Top suite: derbylang Suite to run: derbylang:derbylang Now do RunList Now run the suite's tests Run the tests... Execute command: java -DjavaCmd=java -Doutputdir=C:\derbyt1\derbylang\derbylang -Dtopsuitedir=C:\derbyt1\derbylang -Dtopreportdir=C:\derbyt1\derbylang -Drundir=C:\derbyt1 -Dsuitename=derbylang:derbylang -Dtopsuitename=derbylang org.apache.derbyTesting.functionTests.harness.RunTest lang/arithmetic.sql ...(.more tests).... Generated report: derbylang\_report.txt ``` -------------------------------- ### Sysinfo failure output Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Expected output when the SimpleApp class is missing from the classpath. Indicates that the user-specified class was not found. ```text FOUND IN CLASS PATH: Derby embedded engine library (derby.jar) /home/user/derby/db-derby-10.x.y.z-bin/lib/derby.jar NOT FOUND IN CLASS PATH: user-specified class (SimpleApp) (SimpleApp not found.) ``` -------------------------------- ### Verify PGP signatures with pgp -ka Source: https://github.com/apache/derby/blob/trunk/RELEASE-NOTES.html Alternative PGP verification using the pgp command. Import the KEYS file with -ka, then verify the .asc signature file. ```shell % pgp -ka KEYS % pgp db-derby-X.Y.tar.gz.asc ``` -------------------------------- ### Sysinfo utility success output Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Expected output when the environment is set up correctly. Indicates that Derby Client libraries and the user-specified SimpleApp class were found in the class path. ```text FOUND IN CLASS PATH: Derby Client libraries (derbyclient.jar) /home/user/derby/db-derby-10.x.y.z-bin/lib/derbyclient.jar user-specified class (SimpleApp) /home/user/derby/db-derby-10.x.y.z-bin/demo/programs/simple SUCCESS: All Derby related classes found in class path. ``` -------------------------------- ### Set CLASSPATH to include derbyclient.jar (UNIX ksh/bash) Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Sets the CLASSPATH to include the current directory (location of SimpleApp.class) and Derby's client driver library (derbyclient.jar). Can be skipped if classpath is provided as a JVM launch option instead. ```bash export CLASSPATH=.:${DERBY_HOME}/lib/derbyclient.jar ``` -------------------------------- ### Build Derby javadoc with ant javadoc Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Builds the Derby javadoc. This target takes a while, so be patient. ```shell ant -quiet javadoc ``` -------------------------------- ### Restaurants.java - Connect to Derby Network Server and Perform Database Operations Source: https://github.com/apache/derby/blob/trunk/plugins/eclipse/org.apache.derby.plugin.doc/topics/derby_app.html This Java class connects to the Derby Network Server, inserts a row into the restaurants table, and selects all rows. It uses the ClientDriver and a JDBC URL with create=true to create the database if it does not exist. The shutdown method closes the connection with the shutdown=true property. Ensure the Derby Network Server is running on port 1527 and the myDB database exists in the workspace. ```java package myapp; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.ResultSetMetaData; public class Restaurants { private static String dbURL = "jdbc:derby://localhost:1527/myDB;create=true;user=me;password=mine"; private static String tableName = "restaurants"; // jdbc Connection private static Connection conn = null; private static Statement stmt = null; public static void main(String[] args) { createConnection(); insertRestaurants(5, "LaVals", "Berkeley"); selectRestaurants(); shutdown(); } private static void createConnection() { try { Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance(); //Get a connection conn = DriverManager.getConnection(dbURL); } catch (Exception except) { except.printStackTrace(); } } private static void insertRestaurants(int id, String restName, String cityName) { try { stmt = conn.createStatement(); stmt.execute("insert into " + tableName + " values (" + id + ",'" + restName + "','" + cityName +"')"); stmt.close(); } catch (SQLException sqlExcept) { sqlExcept.printStackTrace(); } } private static void selectRestaurants() { try { stmt = conn.createStatement(); ResultSet results = stmt.executeQuery("select * from " + tableName); ResultSetMetaData rsmd = results.getMetaData(); int numberCols = rsmd.getColumnCount(); for (int i=1; i<=numberCols; i++) { //print Column Names System.out.print(rsmd.getColumnLabel(i)+"\t\t"); } System.out.println("\n-------------------------------------------------"); while(results.next()) { int id = results.getInt(1); String restName = results.getString(2); String cityName = results.getString(3); System.out.println(id + "\t\t" + restName + "\t\t" + cityName); } results.close(); stmt.close(); } catch (SQLException sqlExcept) { sqlExcept.printStackTrace(); } } private static void shutdown() { try { if (stmt != null) { stmt.close(); } if (conn != null) { DriverManager.getConnection(dbURL + ";shutdown=true"); conn.close(); } } catch (SQLException sqlExcept) { } } } ``` -------------------------------- ### Build Derby jar files with ant buildjars Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Builds the Derby jar files. ```shell ant -quiet buildjars ``` -------------------------------- ### SimpleApp derbyclient mode successful output Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Expected output from a successful run of SimpleApp in derbyclient mode. Shows the sequence of database operations performed: connecting, creating a table, inserting rows, updating, verifying, dropping, and committing. ```text SimpleApp starting in derbyclient mode Connected to and created database derbyDB Created table location Inserted 1956 Webster Inserted 1910 Union Updated 1956 Webster to 180 Grand Updated 180 Grand to 300 Lakeshore Verified the rows Dropped table location Committed the transaction SimpleApp finished ``` -------------------------------- ### Run NsTest with DerbyClient or Embedded Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/nstest/README.txt Invoke the main class org.apache.derbyTesting.system.nstest.NsTest. If no arguments are specified, it defaults to a client/server configuration (DerbyClient). The optional 'small' parameter can be added as the second argument to run with a smaller configuration. ```text java org.apache.derbyTesting.system.nstest.NsTest [ DerbyClient | Embedded [ small ] ] ``` -------------------------------- ### Create table and insert/select rows in ij Source: https://github.com/apache/derby/blob/trunk/plugins/eclipse/org.apache.derby.plugin.doc/topics/ij.html SQL statements to create a 'restaurants' table, insert three rows, and select all rows. Run these one line at a time in the ij console after connecting to the database. ```sql create table restaurants(id integer, name varchar(20), city varchar(50)); insert into restaurants values (1, 'Irifunes', 'San Mateo'); insert into restaurants values (2, 'Estradas', 'Daly City'); insert into restaurants values (3, 'Prime Rib House', 'San Francisco'); select * from restaurants; ``` -------------------------------- ### Check out only the Derby plugins directory via SVN Source: https://github.com/apache/derby/blob/trunk/plugins/eclipse/Readme.txt Use this command instead to check out only the UI and Help plug-ins, without the entire Derby source code. The plugins directory contains the source for both plug-ins. ```bash svn checkout https://svn.apache.org/repos/asf/db/derby/code/trunk/plugins ``` -------------------------------- ### Set CLASSPATH to include derbyclient.jar (Windows) Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Sets the CLASSPATH to include the current directory (location of SimpleApp.class) and Derby's client driver library (derbyclient.jar) on Windows. Can be skipped if classpath is provided as a JVM launch option instead. ```batch set CLASSPATH=.;%DERBY_HOME%\lib\derbyclient.jar ``` -------------------------------- ### Sysinfo success output Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Expected output when the classpath is correctly configured. Indicates that all Derby-related classes were found. ```text FOUND IN CLASS PATH: Derby embedded engine library (derby.jar) /home/user/derby/db-derby-10.x.y.z-bin/lib/derby.jar user-specified class (SimpleApp) /home/user/derby/db-derby-10.x.y.z-bin/demo/programs/simple SUCCESS: All Derby related classes found in class path. ``` -------------------------------- ### Connect to Derby Network Server with ij Source: https://github.com/apache/derby/blob/trunk/plugins/eclipse/org.apache.derby.plugin.doc/topics/ij.html Use this ij connect command to create and connect to a database named myDB on the Derby Network Server using the Derby Network Client driver on localhost. The URL includes create=true to create the database if it does not exist, and specifies user 'me' with password 'mine'. ```sql connect 'jdbc:derby://localhost:1527/myDB;create=true;user=me;password=mine'; ``` -------------------------------- ### Build Derby tests sequence Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Run these Ant targets in order to build the Derby tests. Requires JUnit to be downloaded. ```shell ant -quiet clobber ant -quiet all ant -quiet buildjars ``` -------------------------------- ### RunTest with verbose property Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Shows more detailed output when set to "true". ```bash java -Dverbose=true org.apache.derbyTesting.functionTests.harness.RunTest lang/arithmetic.sql ``` -------------------------------- ### Run Derby Sysinfo utility Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Runs Derby's Sysinfo utility to test the classpath for an embedded environment. Provide the arguments 'embedded' and 'SimpleApp.class' to verify the presence of the SimpleApp class. ```bash java org.apache.derby.tools.sysinfo -cp embedded SimpleApp.class ``` -------------------------------- ### View Ant targets for the Scores demo Source: https://github.com/apache/derby/blob/trunk/java/demo/scores/README.html Run this command in the scores demo directory to see the Ant targets that build and run the application. Follow the instructions in the output; you may need to download the Jakarta Commons Math library and customize a property before using 'ant run'. ```bash ant -projecthelp ``` -------------------------------- ### Ant build output for derbyTesting package Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Typical output when building the derbyTesting package using ant.ksh. Shows compilation and copying of files to the classes directory. ```text > cd /local/derby/java/testing > ant.ksh Searching for build.xml ... Buildfile: /local/derby/java/testing/build.xml compile: [javac] Compiling 30 source files to /local/derby/classes ... [copy] Copying 1 file to /local/derby/classes/org/apache/derbyTesting/funct ionTests BUILD SUCCESSFUL Total time: 10 minutes 3 seconds ``` -------------------------------- ### Set CLASSPATH and PATH for Derby tests Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Sets up environment variables for running Derby tests. $jardir and $tstjardir are convenience variables pointing to the Derby and JUnit jar directories respectively. The CLASSPATH includes derbyrun.jar, derbyTesting.jar, and junit.jar; PATH includes the JDK bin directory. ```shell set jardir=/local/derbyjar set tstjardir=/local/testingjars set CLASSPATH="$jardir/derbyrun.jar:$jardir/derbyTesting.jar:$tstjardir/junit.jar" set PATH=/local/jdk141/bin:$PATH ``` -------------------------------- ### Verify PGP signatures with pgpk/pgpv Source: https://github.com/apache/derby/blob/trunk/RELEASE-NOTES.html Commands to verify the PGP signature of a Derby distribution using PGP (pgpk/pgpv). First import the KEYS file, then verify the .asc signature file. Replace X.Y with the actual version. ```shell % pgpk -a KEYS % pgpv db-derby-X.Y.tar.gz.asc ``` -------------------------------- ### Compile Derby sources with ant buildsource Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Compiles all source files needed for the Derby product. ```shell ant -quiet buildsource ``` -------------------------------- ### Set CLASSPATH on UNIX (ksh/bash) Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Sets the CLASSPATH to include the current directory and Derby's embedded driver library (derby.jar). Required to run SimpleApp. ```bash export CLASSPATH=.:${DERBY_HOME}/lib/derby.jar ``` -------------------------------- ### Compile all Derby sources with ant all Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Compiles all Derby source files, including test classes. Requires the JUnit test framework to be downloaded. ```shell ant -quiet all ``` -------------------------------- ### Ant derbytestingjar build output Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Output from running the jar build target 'derbytestingjar' at the ${derby.source} level to create derbyTesting.jar. ```text c:> ant derbytestingjar Searching for build.xml ... Buildfile: C:\derby\build.xml initjars: [mkdir] Created dir: C:\derby\jars\ [mkdir] Created dir: C:\derby\jars\lists [echo] Revision number set to exported [echo] . derbytestingjar: [echo] Beginning derbytesting.jar build ..... BUILD SUCCESSFULL ``` -------------------------------- ### derbynetclientmats.properties suite configuration Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Specifies additional properties for all tests in the derbynetclientmats suite, including the framework, referenced suites, JDK12 testing, J9 exclusion, and a timeout. This file works alongside the derbynetclientmats.runall file. ```properties framework=DerbyNetClient suites=derbynetclientmats derbynetmats jdk12test=true runwithj9=false timeout=60 ``` -------------------------------- ### Summary results from derbylang_report.txt Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Expected output from a successful test run: no failures, empty _fail.txt, and no failures in the Summary results section. ```text ----------------------------------------------------------- Summary results: Test Run Started: 2004-11-10 11:27:55.0 Test Run Duration: 00:04:09 129 Tests Run 100% Pass (129 tests passed) 0% Fail (0 tests failed) 0 Suites skipped ``` -------------------------------- ### SimpleApp successful run output Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Expected output from a successful run of SimpleApp in embedded mode. Shows database creation, table operations, and normal Derby shutdown. ```text SimpleApp starting in embedded mode Connected to and created database derbyDB Created table location Inserted 1956 Webster Inserted 1910 Union Updated 1956 Webster to 180 Grand Updated 180 Grand to 300 Lakeshore Verified the rows Dropped table location Committed the transaction Derby shut down normally SimpleApp finished ``` -------------------------------- ### RunTest with testSpecialProps property Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Sets additional properties, with multiple properties separated by '^'. ```bash java -DTestSpecialProps=derby.infolog.append=true org.apache.derbyTesting.functionTests.harness.RunTest lang/arithmetic.sql ``` -------------------------------- ### RunTest with jvmflags property Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Sets specific JVM properties for each JVM instantiated by the test harness, separated by '^'. Note that setting only initial or max heap size may cause incompatibilities. ```bash java -Djvmflags=-Xms32M^-Xmx128M org.apache.derbyTesting.functionTests.harness.RunTest lang/concateTests.java ``` -------------------------------- ### RunTest with derbyTesting.encoding property Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Allows running the harness with a different encoding. Only supported with jdk15. ```bash java -DderbyTesting.encoding=UTF-16 org.apache.derbyTesting.functionTests.harness.RunTest jdbcapi/resultset.java ``` -------------------------------- ### Redirect output and errors to a file Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/nstest/README.txt Set the system property 'derby.nstest.outputFile' to a file name to redirect output and errors to that file. ```text -Dderby.nstest.outputFile=fileName ``` -------------------------------- ### Run Sttest from command line Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/sttest/README.txt Run the Sttest class from the command line. Requires Java and Derby jars including derbyTesting.jar in the classpath. ```bash java org.apache.derbyTesting.system.sttest.Sttest ``` -------------------------------- ### Check Ant user.home with ant -diagnostics Source: https://github.com/apache/derby/blob/trunk/BUILDING.html Run this command to find out where Ant thinks your home directory is, which is where it looks for the ant.properties file. Look for 'user.home' in the output. ```shell ant -diagnostics ``` -------------------------------- ### Run Sttest with output redirected to file Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/sttest/README.txt Run the Sttest class and redirect both stdout and stderr to sttest.out. The output file will include warnings and errors. ```bash java org.apache.derbyTesting.system.sttest.Sttest>sttest.out 2>&1 ``` -------------------------------- ### Run a single Derby test with embedded driver Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Runs the supersimple test against the embedded driver using the RunTest harness. The test is specified as lang/supersimple.sql. A successful run produces a .pass file; a failed run produces a .fail file and shows differences in console output. ```shell java org.apache.derbyTesting.functionTests.harness.RunTest lang/supersimple.sql ``` -------------------------------- ### Generate UTF-8 output with -DgenerateUTF8Out Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Creates a .utf8out file containing the test output converted to UTF-8, useful when developing on non-ISO-8859 systems. Avoid file transfer programs that might modify the file (e.g., ftp in ascii mode). ```shell java -DgenerateUTF8Out=true org.apache.derbyTesting.functionTests.harness.RunTest lang/supersimple.sql ``` -------------------------------- ### derbyall.properties suite definition Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Defines the derbyall suite by listing other suites in the 'suites' property and setting debug and logging properties. This file is in the suites directory and refers to other .properties or .runall files. ```properties suites=derbylang derbynetclientmats derbynetmats storeall xa derbytools derby.debug.true=enableBtreeConsistencyCheck derby.stream.error.logSeverityLevel=0 ``` -------------------------------- ### restaurants.sql script for ij Source: https://github.com/apache/derby/blob/trunk/plugins/eclipse/org.apache.derby.plugin.doc/topics/ij2.html SQL script to run with ij in Eclipse. Must include a connection command first, as no default connection exists. The script connects to a Derby database, inserts, updates, selects, disconnects, and exits. ```sql connect 'jdbc:derby://localhost:1527/myDB;create=true;user=me;password=mine;'; insert into restaurants values (4, 'Grande Burrito', 'Oakland'); update restaurants set city = 'Ukiah' where name = 'Irifunes'; select * from restaurants; disconnect; exit; ``` -------------------------------- ### getString() - clarification and extensions Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tools/org/apache/derby/jdbc/package.html Clarifies the behavior of getString() for binary types and documents extensions for CLOB and BLOB columns. For binary types, returns a String containing a two-character hexadecimal representation for every byte in a non-null value. For CLOB columns, returns a String representing the CLOB contents; for BLOB columns, supported with conversion as a binary type. ```APIDOC ## getString() - clarification and extensions ### Description Clarifies the behavior of getString() for binary types and documents extensions for CLOB and BLOB columns. For binary types, returns a String containing a two-character hexadecimal representation for every byte in a non-null value. For CLOB columns, returns a String representing the CLOB contents; for BLOB columns, supported with conversion as a binary type. ### Method getString() ### Behavior - For binary types (Types.BINARY, Types.VARBINARY, Types.LONGVARBINARY, Types.BLOB): - Returns a String containing a two-character hexadecimal representation for every byte in a non-null value. - The two characters are in the range '0' - '9' and 'a' - 'f'. - For NULL values, null is returned. - Note: This String does not match the contents of the stream returned by getAsciiStream() or getCharacterStream() on the same column. ### Extensions - Types.CLOB columns: Returns a String representing the contents of the CLOB value if it is not NULL; returns null if NULL. - Types.BLOB columns: Supported with conversion as a binary type. ``` -------------------------------- ### Set CLASSPATH on Windows Source: https://github.com/apache/derby/blob/trunk/java/demo/simple/example.html Sets the CLASSPATH to include the current directory and Derby's embedded driver library (derby.jar) on Windows. ```batch set CLASSPATH=.;%DERBY_HOME%\lib\derby.jar ``` -------------------------------- ### Disable backup, restore, and re-encryption Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/system/nstest/README.txt Set the system property 'derby.nstest.backupRestore' to 'false' to turn off backup, restore, and re-encryption. Default is 'true'. ```text -Dderby.nstest.backupRestore=false ``` -------------------------------- ### Deploy with GPG passphrase Source: https://github.com/apache/derby/blob/trunk/maven2/README.txt Use this Maven command to deploy artifacts to the Apache staging repository. Replace the placeholder with your actual GPG passphrase. ```bash mvn -Dgpg.passphrase="my secret passphrase" deploy ``` -------------------------------- ### derbyTesting.jar.path property setting Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Required to run upgrade tests. Points to the location of jar files from a previous release. The property should be set as follows. ```properties derbyTesting.jar.path=${jar_location} ``` -------------------------------- ### getXXX() - NULL value handling extension Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tools/org/apache/derby/jdbc/package.html Describes Derby's extension to the JDBC getXXX() methods for handling SQL NULL values. If the column value is null, any getXXX method can be used to fetch the null value, returning null or a zero representation, with wasNull() returning true. ```APIDOC ## getXXX() - NULL value handling extension ### Description If the value column is null, then generally any getXXX method can be used to fetch the null value and a null or a representation of zero will be returned and a subsequent call to wasNull() will return true. It is not recommended that applications take advantage of this liberal conversion of SQL NULL values; use of a getXXX() method that works against NULL and non-NULL values is strongly recommended. ### Method getXXX() ### Notes - This is an extension to the JDBC specification. - Applies to all getXXX() methods. ``` -------------------------------- ### Set derbyTesting.jar.path for upgrade tests Source: https://github.com/apache/derby/blob/trunk/java/org.apache.derby.tests/README.htm Use this JVM flag when running upgrade tests from a location where the previous Derby release jars are not in the default svn-built location. The path must point to a directory containing a subdirectory named by major.minor version. ```bash -Djvmflags=-DderbyTesting.jar.path={path_to_derby_jars} ``` -------------------------------- ### View all limits with ulimit -a Source: https://github.com/apache/derby/blob/trunk/java/demo/vtis/svn_log.txt Use this command to see the new/all limits after changing the open file descriptor limit. ```bash $ulimit -a ```