Few days back, I had blogged about “Tryst with MySQL“. Today, I shall move ahead and give an insight on database management with MySQL using NetBeans.
Its meant for Windows user only, rest can follow too, though just for the content and may try exploring these steps for their OS as well.
MySQL Tools -
Apart from being a popular open source database. It also has some amazing tools, which have been formed, due to years of users invaluable feedback, on their forums. Here’s what the website describes about MySQL Administrator;
MySQL Administrator is a powerful visual administration console that enables you to easily administer your MySQL environment and gain significantly better visibility into how your databases are operating
Lets understand in a simple, yet an interesting manner, how can we configure MySQL Server using it.
MySQL Community Server 5.0 -
Its free, thats why I used it! Also, its supported by NetBeans 6.0 and 6.1 FCS. Anyways, there are two methods of setting up the server, either by installing OR by not installing. Surprised! I was too, when I encountered this on their website.
So, you need to download the appropriate version and get started. if you go for installation, then just install it, by running the appropriate installer. By the way, its cross-platform, I guess you all might know this
If you go for the other, that means you are a hard working soul, who likes getting deep into the technicalities of the stuff, and if its open source then why not? So, download it and then, you could follow a long series of steps to get started (Refer to this MySQL Documentation) OR you could go my way.
I had tried the later one and it took 1-2 hours, to get things running smoothly. Now, I am going to make your life simple and easy. So, lets get rolling;
- Download the archive, if you still have not done it.
- Extract it and store it where ever you feel, but I would recommend storing it in C:/ if you are a Windows user, under a MySQL folder.
- Now, download the MySQL Admin tool, and install it.
- After installing, create a short-cut for MySQLAdministrator.exe (on the Desktop), stored under this kind of folder, C:/Program Files/MySQL/MySQL Tools for version/
- Run this application, it will prompt you for a connection host, port username and password.
- Just press Ctrl, don’t release it and click on Skip button, which is initially the Cancel button.
- Click on Service Control, in the left panel and then, click on Configure Service Tab. Here, you would see a button at the bottom the UI, click on Install new Service. Name it as MySQL.
- OR, you can right-click inside the Installed Services section, in left panel. A context-menu pops-up with 3 options. Select Install new Service. Name it as MySQL.
- Now, do the following entries; what I did I just made two changes there. In the Config Filename text-field, enter the path of the my.ini, its the option file.
- You may either create option file on your own, OR you may copy some pre-defined option files, stored in MySQL Server extracted folder.
- Copy any one of the files having my- as prefix and copy, paste it into the data folder in that directory, rename it to my.ini
- Now, back to the Admin, in the Path to binary field, browse to the bin folder inside the MySQL Server extracted folder.
- Then, click button – Apply Changes. Switch over to the Startup Variable Tab. Click button – Choose Option File and browse to the directory, where we had created the my.ini file.
- Check the following checkboxes -
- TCP Port: 3306
- Base Directory: C:/Program Files/MySQL/mysql-5.0.51a-win32
- Data Directory: C:/Program Files/MySQL/mysql-5.0.51a-win32/data
- Default Storage – that’s upto you, I selected InnoDB.
- Apply changes and switch to Service Control and then, Start/Stop Service. Now, press Start Service.
- You are ready to use MySQL Server. Click on File Menu and select New Instance Connection…
- Again, you would see the prompt which you had earlier came across, this time, don’t alter default values, just click OK.
- Now, it would show the Administrator with all the options, which the user must access to administer database, manage connections, add/delete users and grant/revoke privileges.
MySQL and NetBeans -
So, you want to use MySQL with NetBeans, I guess Java is your language of choice for development in NetBeans, as it provides such a fabulous Java Editor since 6.0 FCS and now, its really amazing in 6.1 FCS. You could try making a database application using Swing Application Framework, which lets you create a CRUD application.
Here is a fantastic tutorial, which would enable you to get started with MySQL database management using NetBeans.
Today, I tried all this and started working with MySQL, it was good, everything worked smoothly, until the following happened.
I had an issue while trying to disconnect database using the Admin tool, ran by NetBeans Database Explorer. So, I have filed a bug report, just click that link, to see more details and an attached image too, justifying my point.
This is being submitted for review to the blogging contest – Student Reviews NetBeans 6.1 and OpenSolaris!
Author – Varun Nischal, University - JIIT University