YOUR FEEDBACK
ASP.NET
mark bosley wrote: Good article. Please post the code or send it to me. It ...
AJAXWorld RIA Conference
$300 Savings Expire July 25
Register Today and SAVE!


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP COLDFUSION LINKS


Working with the Apache Derby Database and ColdFusion
A basic introduction

Digg This!

Page 2 of 2   « previous page

Working with the Network Server Using ij
If you're really interested in using Derby, you'll probably want to install its tools. Adobe includes the tools classes in the base install, but doesn't include the nice scripts that are part of the Derby distribution and make using the tools that much easier. If you've downloaded Derby, you can copy the contents of its bin directory into ColdFusion's. This gives you scripts like sysinfo and dblook that you can use to get information about your Derby installation and its databases. Also included is ij, a SQL*Net-like console for interactively sending SQL commands to either an embedded or network database.

Navigate to the bin directory where you installed the Derby scripts. Open a command prompt and run setNetworkClientCP. Now run ij. The program will echo its version and give you a new command prompt:

ij Version 10.2
ij>

Now connect to the database you created with the ColdFusion Administrator (named test2 in the screenshot above) by typing this at the command prompt: CONNECT 'jdbc:derby://localhost:1527/test2;create=true'; Ij will return a prompt and you're connected. You can now start creating tables and having lots of fun. To be honest, unless you're used to interacting with your database on the command line, you'd be better off sending your CREATE TABLEs through CFQuery or better yet, using IBM's Eclipse plug-in.

Using IBM Cloudscape Workbench Plug-in for Eclipse
IBM provides an excellent plug-in for working with databases. You can use it to connect to DB2, Oracle, SQL Server, MySQL, Sybase, Informix, and oh, yeah, Derby. You can then use a nifty tree-type browser to navigate the objects in your database. There's no visual query builder or simple table creation dialog, but if you want to explore a database, sample table data, or test your queries inside of Eclipse it's not bad. Get started by visiting IBM DeveloperWorks and downloading the CS Workbench plug-ins (skip the StandAlone version): www.ibm.com/developerworks/db2/downloads/csworkbench/. Unpack the csworkbench_plugins_1.0.zip archive into your Eclipse installation and restart Eclipse if necessary. Go to the Window menu->Show View->Other... and select Data->Database Explorer. Now you have a new View open at the bottom of your screen with a folder labeled Connections. Right-clicking on this let you create a New Connection. You can give it a whirl with one of the example embedded databases. You have to tell Eclipse the Database Location and the location of the Derby driver (which is in derby.jar). (Figure 4)

Remember that once you connect to an embedded database with Eclipse, ColdFusion won't be able to until you Disconnect. If you so much as Verify your Datasource in ColdFusion, you won't be able to connect with Eclipse until you restart the CF server. If you created a network database and have the Derby server running, you can connect to that without worrying about locking the connection. Select Derby Client JDBC Driver from the list in the New Connection dialog instead. The screenshot below shows the Derby Client dialog. It looks like a resource bundle got misplaced in my install, so NO_RESOURCE_FOUND is showing where 'JDBC Driver Class,' 'Class Location,' and 'Connection URL' should appear. In this case 'Class Location' should indicate the location of derbyclient.jar. Even if you didn't specify a password when you created your database, you'll have to specify one here.

Here you can see the database browser contents for the Book Club example database. Right-clicking on a table gives you the option to browse the table data.

Packaging Your Database for Distribution
One of the prime reasons for using Derby is to make it easy for other ColdFusion users to install your system. You know the target database platform exists on all ColdFusion 8 servers, regardless of operating system. So how do you package your application for deployment on the machines of your potential clients? Use the Packaging and Deployment wizard in ColdFusion Administrator. There isn't enough space here to cover this feature fully, but it's easy enough to figure out. If you want to package up your CF files, Derby database, and Datasource, simply add the directory containing your application and the directory containing your Derby database under "Assoc. Files/Dirs" in the wizard. Next add the Datasource. Build your Archive and send it out to your client. They should be able to use the same wizard in reverse. If the database files are placed in the same location relative to Derby, the Datasource should continue to work. If the deployer changes the database deployment path, he will have to update the Datasource to reflect this change.

Conclusion
Derby is very well documented and you can find stacks of reading material to fill your free time at http://db.apache.org/derby/. This article is a basic introduction to get you started using Derby as installed with ColdFusion 8. For more technical details on performance, SQL standard compatibility, and Derby's Java API, head to Apache. Since Derby's whole API is exposed in Java, it plays very nicely with CF. You can do all sorts of crazy things directly to the database - imagine creating a whole new database (in two lines of CFScript), then populating it, zipping it up, and sending it to the browser embedded in an applet. It's not hard to think of a system that creates and packages offline systems... sounds like a good article.

References
http://db.apache.org/derby/
http://wiki.apache.org/db-derby/SQLvsDerbyFeatures
www.ibm.com/developerworks/db2/downloads/csworkbench/
http://squirrel-sql.sourceforge.net/index.php?page=faq

At press time, ColdFusion 8 was still in beta and the documentation incomplete.


Page 2 of 2   « previous page

About Chip Temm
Over the past decade, Chip Temm moved from North America to Europe and on to Africa where his company anthroLogik solutions provided analysis and development services to non-governmental organizations across seven timezones. He is currently back in Washington, DC where "remote development" means working from home and "wildlife" means raccoon.

CFDJ LATEST STORIES . . .
Adobe's Kevin Lynch and Microsoft's Scott Guthrie to Keynote AJAX World RIA Conference & Expo
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted to be
Voyager Offers Android, .NET CF, Java Runtime Support
Recursion Software released a private beta version of their Voyager mobile platform, with powerful interoperability for Android, Microsoft .NET and Compact Framework (CF), all Java editions (JME CDC, JSE and JEE), and more than 15 embedded operating systems. The Voyager platform is a p
AJAX and Enterprise RIA Tools - JSF, Flex, and JavaFX
2008 is going to be an important year for Rich Internet Applications. Most organizations are delivering or planning to deliver Rich Internet Applications; however, at the same time, most IT managers are facing a dilemma: which Rich Internet Application technology and platform to use? T
CFDynamics Announces Renewed Agreement with SmarterTools
CFDynamics, a ColdFusion web host, has renewed an agreement with SmarterTools that will allow them to pass on immediate value to their customers. When a customers signs up for a dedicated hosting account they will now receive $750 worth of features including SmarterMail, SmarterStats a
Microsoft's Virtualization Chief Mike Neil To Keynote SYS-CON's Virtualization Conference & Expo
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec
SYS-CON's Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE