Accessing Derby from Creator
Yes, I'm a NetBeans guy, but since Creator 2's been released, I can't stop playing with it. Since I've also been playing with Derby a bit lately, and Derby isn't one of the preconfigured database server types that ships with Creator, I thought a short blog entry might be in order.
Getting Started
- Download the latest official Derby release (10.1.2.1 at the time of this writing) and extract the archive.
- Set the DERBY_INSTALL environment variable to point to your Derby installation location. For me this is D:\db-derby-10.1.2.1-bin.
Start the Derby Server
- Open a command prompt and switch to the $DERBY_INSTALL/frameworks/NetworkServer/bin directory.
- Execute the setNetworkServerCP script, which sets the necessary Derby jars on the classpath.
- Execute the startNetworkServer script to start Derby. You should then see something like the following:
Add Derby Database Type to Creator
- Start Creator and switch to the Server's window (Ctrl+Alt+S).
- Right-click the Data Sources node and choose Edit Database Server Types.
- Click New and browse to the $DERBY_INSTALL/lib directory and select derbyclient.jar.
- Set the Display Name to Derby.
- Click Suggest to retrieve the Driver Class Name (org.apache.derby.jdbc.ClientDriver).
- Enter the following for the URL Template: jdbc:derby://#HOSTNAME:1527/#DATABASE. The completed dialog should look as follows.

Add a Derby Data Source
- Right-click the Data Sources node and choose Add Data Source. Set the following:
- Data Source Name: derbyDB.
- Server Type: Derby.
- Database Name: derbyDB
- User ID: APP
- Password: APP
- Database URL: jdbc:derby://localhost:1527/derbyDB;create=true
- Validation Table: SYS.SYSCHECKS
- Click Test Connection:

- Then click OK and Add to add the derbyDB data source.
- By default, we see all the database schemas, including the sytem schemas. Right-click derbyDB and choose Modify Data Source.
- Switch to the Schemas tab and click Get Schemas.
- Click Clear and then select just the APP schema.
- Click Modify to close the Modify Data Source dialog.
Execute a SQL Script
- Customers.sql will create 3 tables and populate them with data - save it somewhere on your hard drive. Right-click the derbyDB data source and select View Data. Click the folder icon to Import a File containing SQL commands and open the Customers.sql file.
- Click Run Query. You'll see output like the following:
- Now right-click the derbyDB data source and select Refresh.
- Expand the Tables node to see the 3 tables that were created.

- Right-click the CUSTOMER_TBL and choose View Data:
Use the Data Source in an Application
- Create a new JSF Web Application project named DerbyData.
- Drag a Table component onto Page1.
- Switch to the Servers window (Ctrl+Alt+S) and drag the CUSTOMER_TBL from the derbyDB data source onto the table component on Page1.
- Run the project (Ctrl+F5).
- Login or register to post comments
- Printer-friendly version
- bleonard's blog
- 956 reads





