July 3, 2020
Hot Topics:

Binding to MySQL in Java Studio Creator

  • By Dick Wall
  • Send Email »
  • More Articles »

Originally, I was planning to use this article to cover use of Java Studio Creator for simple Web apps that could be used on a mobile phone, but I realized that this and other articles I was planning to write about would require data in something a little more complete than the pointbase Java database that comes with Java Studio Creator by default.

Creating database-driven apps requires a database, and that requires data. This makes it necessary to create schemas and populate them with some sample data. This is of course possible with pointbase, but without any admin tools it means writing a bunch of SQL and just takes longer than if you have access to some higher-level tools.

Also, for many people working on a project, at least right now pointbase is probably not a consideration. Serious contenders for backend databases for J2EE enterprise Web apps of course include Oracle, DB2, SQL Server, and a host of other commercial options. On top of that, many people wanting something a bit higher in the food chain but maybe without a lot of cost may consider Postgres, Firebird, or MySQL. It is the latter I have chosen for my future examples, since it is quick and easy to download and install on any supported platform (which is pretty much all of them), is simple to use, and has some very nice higher-level support tools. More importantly, it also has a JDBC driver (essential for use in Java Studio Creator).

That said, most of the points in this article about using Java Studio Creator with MySQL above are transferable to other databases. I will not attempt to cover the installation and administration of those other databases, because if you want to use them you probably know that already. However, I will point out the points where JDBC setup, database URL template setup, and other places that are likely to be customized for different databases.

MySQL is chosen because future articles I write will include scripts to set up and populate MySQL databases with data that will be used for the examples. If you want to try and adapt these to other databases to follow the articles, I wish you luck, but politely decline to offer technical assistance in converting the data across to the database of your choice.

Gathering and Installing the Software

The first step will be obtaining MySQL, the JDBC drivers, and (optional) some tools that make working with MySQL easier.

Depending on your platform, you may already find that you have MySQL installed on your machine. Most Linux distributions in particular come with MySQL either installed by default, or in the accompanying software packages with your distribution. You can use the software installation application included with your version of Linux to search for and install MySQL if it is provided. Failing that, you can download binaries for Linux from the same place as binaries for Mac and Windows.

For all platforms, if you need to install MySQL (and on Windows and MacOSX you probably will), the downloads page is:


There are quite a lot of different versions, so you may need to scroll down to find the platform binary you need.

After download, installation will be what you are expecting on your platform—probably RPM for Linux, msi for Windows, and dmg for MacOSX. Install as you would any other app; you should hit no problems.

If you are prompted for a root or admin username and password, remember what they are because you will need them later.

You also need to grab the JDBC driver for MySQL; the download page for this is:


The binaries are pure Java jars; hence, they are the same across all platforms. Just grab the zip or tar.gz based on your preference, and unzip or untar it. Once done, find the mysql-connector-java-3.1.8-bin.jar file (the number may be higher depending on when you read this article) and copy it to somewhere that makes sense on your machine. You are going to have to tell Creator about this jar file when you want to use MySQL, so put it somewhere you can remember.

As an optional step, also grab the MySQL Control Center from


This is an older tool for which support has dropped, but still one I find very useful.

Depending on your install, you may have chosen not to run MySQL by default. On Windows if you did this, you should start the MySQL Service from the services; on Linux, start the service as standard for your distribution. If it is pre-installed on Linux, the chances are it is already running.

Finally, I can highly recommend phpmyadmin if you are so inclined (http://www.phpmyadmin.net/home_page/). It requires a PHP installation on a working Web server to run, and I will not cover the installation of that here. Suffice to say that I like it better than MySQLCC even though you have to have Apache with PHP or similar running first.

If you do have trouble with any of these steps, I would refer you to the excellent guide at


which is an excellent step-by-step guide for setting up MySQL on Linux and Windows. Hopefully, it will also provide some useful pointers to MacOSX users and others out there as well.

Add an Example Database

Download MySQLCreatorDemo with the example project in it and unpack it to a suitable directory. Inside, you will find a Java Studio Creator project, and also a file called creatordemo.sql. This is a MySQL dump file that you can restore into a complete schema with example data. To do this:

bring up a command window and log in in to MySQL using the following command:

mysql -u root -p

And enter the root password you selected on install when prompted.

If you chose not to use a root password, leave off the -p off at the end.

When you see the mysql> prompt, type the following command:

create database creatordemo;

then type


Next, you want to import the schema and data. This step also creates a user called creatordemo with a password of creatordemo to access the database you are populating.

From the command line, type:

mysql -u root -p creatordemo < creatordemo.sql

You should now have the demo database ready to use in Creator.

Page 1 of 2

This article was originally published on June 21, 2005

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date