Geertjan's Blog

  • June 6, 2006

Connecting to a Database from a NetBeans Platform Application

Geertjan Wielenga
Product Manager
I'm looking at a tutorial by Talley Mulligan, which builds on his excellent GUI Building in NetBeans IDE 5.0. In the continuation, which should be available in the next few weeks, he shows how to hook a database to the user interface. However... since the user interface is built in Swing, I thought: "Hmm. Couldn't the NetBeans Platform be helpful in some way?" So, instead of reviewing the tutorial by implementing it in a standard (boring) J2SE application, I built a standalone rich-client application instead. The steps I took for building the user interface and hooking it up to the database were identical to how they were described in the tutorial. The only difference was that I used different project templates and that I made sure to bundle the driver JAR file with the application. Since I also wanted to make the Google toolbar available to the application, I included some IDE modules that provide the Update Center wizard and an external HTML browser. And here's the result:

The data you see above comes from a Derby (Java DB) database. When you click Add, you get the dialog box described in GUI Building in NetBeans IDE 5.0:

And, because the tutorial makes use of a technique described by John in Swing Tutorial in Matisse - Custom Table Models, I can even see the live data in my database before deploying the application, while it is in design mode:

So, at around about the time that Talley releases his tutorial, I'll be releasing a NetBeans Platform tutorial that outlines the same subject, but from a NetBeans Platform perspective. It's pretty cool to finally have an application, with its own executable, that connects to a database. And really cool that creating applications on the NetBeans Platform requires the same basic skills as creating any other Swing application. Of course, the benefit is that now that the application is on the NetBeans Platform, adding additional functionality to it is as easy as adding modules to NetBeans IDE. The Update Center wizard rocks.

Join the discussion

Comments ( 2 )
  • Rodrigo Atanes Batistelo Friday, March 6, 2009

    The tutorial is ready to crud in the NetBeans platform?? I work in Hospital of Clinics in São Paulo- Brazil and there is much interest about netbeans platform, we would like to create an Electronic medical records starting in this hospital that is one of the main brasilian hospitals. I need a good example of CRUD application, in NetBeans platform to try to convince then to use it. Initially I would like to put a small CRUD application in the NetBeans platform, where today there is the persistence in JDO, but then convince them to implement the national electronic medical records. I have support from some important people in the hospital for this. Help me Please, com examples, suggestions and so on.

  • guest Saturday, May 21, 2011
    Visited your tutorial at:
    Liked it. I am new in Java and NetBeans. I was looking for the second part of the above tutorial.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.