Skip to main content

LeagueSite: Creating a db with Java Studio Creator 2

Posted by joconner on October 9, 2006 at 12:05 AM PDT

I began using Java Studio Creator 2 just a couple weeks ago in an effort to create a Java technology based website for my community's Little League. My first task was to create a database. I started using Creator with the impression that it would assist me with that. I had read that Java Studio Creator 2 provides easy access to existing databases and their tables. That might be true, but the tool doesn't help much to create a new database. I figured it out, but it wasn't obvious. I thought I'd share how I did it.

I've already decided to use Java DB (Apache Derby), so I'll use use the built-in app server and bundled database (Apache Derby) until I'm ready to deploy. The first step was to start the db server. On the left side of Creator, you can right-click on the "bundled database" and choose to start it up.

startdb.png

Then you need to create a data source. Right-click on the "Data Source" folder under the "servers" view, and you get to fill in a form like this:

createtable1.png

I didn't realize at first that this did not create my table...it merely created a data source link to something that Creator thinks already exists. When I clicked on the data source "LeagueSite" to add tables, Creator complained:

connectionfailed.png

So, Creator won't actually create the db, but it'll link to it if it exists. But wait...I remember something about Java DB (Derby). I need to add something to the db url to create a new database. I try again, this time adding "create=true" to the URL:

createtable2.png

I hear the hard drive spin around. That's good; something is happening this time. The db exists, but has no tables...I hope. The new data source appears in the list, but something still seems wrong...there's a little red 'x' on the data source folder. That doesn't look good.

leagusitewarning.png

I right-click on the data source and choose "Refresh"...hey I'm experimenting, and I think the warning 'x' might go away. Nope. An even bigger warning pops up, this time in its own dialog box. Oh boy, I'm in trouble now.

novalidationtable.png

No, no...I'm not in trouble. This is good. I just don't have a "validation" table to validate my connection. But the "Connection Status" says "succeeded." OK, sure...whatever. I have a db, just no tables. I expected that. Good so far.

Now that I have a db, I no longer need "create=true" in the db url. I modify the data source to remove the url option. But how do I create tables? There's no visual tool to design tables...oops. I kinda, sorta expected that since this is a visual design tool, but the db creation area is obviously not the focus of the tool. Easy access to an existing database and its tables is clearly supported, but no one expected me to use this tool to actually create a db.

I right-click on the data source again. This time I see a "view data" option. Sounds promising even though I know there's no data yet. Hehe...maybe I'll make it crash.

viewdataoption.png

No crash. Instead, a SQL query window pops up. Good, I can query my tables once I have them. But wait...maybe I can use this "query" window to actually "create" a table. After fumbling around with the create syntax, I finally get it right. I type in my table creation statement for Java DB and hit "Run Query":

createroletbl.png

It worked. Nice. Now that I have a table, maybe I can use this for the validation table that Creator wants so bady. After modifying the data source once again, indicating my newly created table, that little red 'x' goes away. I'm a db idiot, but this isn't so hard. Now I can browse my table. There's no data yet, but the ROLE_TBL is there.

viewroletbl.png

If I can create a new table, I can probably populate it too. I can't find any other convenient GUI tool within Creator to help me with this, so I just use this little query window to create an INSERT statement. Hmmm...not so fast. I will eventually need a maintenance screen in my app to manage this table's data, so I'll populate this table using that screen after I create it.

Java Studio Creator 2's strength isn't database creation and design, and I don't think it ever advertised itself for that. I just assumed that it would have a wizard or two for that purpose since it does seem to fit into the rapid application development tool category. I do expect it to shine when I need to create data aware web pages. It supposedly excels at linking JSF components to existing data sources. We'll see about that soon enough when I create that maintenance page for this table.

That's all for now. Just thought I'd let you know where I am on that project. I'm not far along at all, but I did promise to keep you filled in on my progress. And that's it so far. It's not much, but I've learned a little about Java Studio Creator already. In the next couple days, I'll try to link up components on a page to my db. Wish me luck!

Related Topics >>