SQL Editor and NetBeans | #1

In the previous blog, I mentioned SQL Editor. NetBeans has improved it in every release in the past 2 years and it looks great these days. Here’s a sneak-peek;

Click to enlarge!

This figure shows the SQL Editor window along with the results shown for the command executed, written in the editor (select * from nbusers). Also, you can see numerous toolbar buttons, and results are shown in similar way as if it was any CRUD application. We will discuss this in more detail in following section and follow-up blogs.

Key Features..

Execute Command

To execute any SQL query within the NetBeans IDE, you must write the necessary queries in the SQL Editor shown above. Then, you may use a shortcut key (Ctrl-Shift-E) or make use of the icon (Run SQL (Ctrl+Shift+E)), clicking this toolbar button will execute the queries against the selected database (shown in drop-down list of Connection‘s), and relevant feedback is generated in the Output window (see figure). Also, results are shown as mentioned earlier.

Click to enlarge!

SQL History

Now, we will have a look at another cool feature, known as SQL History. You can read more about it on some of the Sun blogs written by;

John Baker

A new database feature in NetBeans 6.5 is the ability to save and reuse SQL statements that have been executed. A dialog listing SQL statements along with the date executed can be opened from the SQL Editor by right-clicking within the editor and choosing SQL History or clicking an image button for SQL History in the SQL Editor toolbar.

James Branam

The order the statements appears in is descending, the more recently executed statement appears at the top of the dialog. To help search for an SQL statement, you can choose the connection for the database against which the statement was executed.

Here’s a quick view of the feature;

Click to enlarge!

Integration with Database Explorer

This is also one of the coolest features about SQL Editor, i.e. its integrated with Database Explorer shown in Services window, goto “Window | Services” or hit the shortcut keys (Ctrl+5) on Windows Operating System to access the window.

Click to enlarge!

This figure shows Database Explorer on the left, while the SQL Editor on the right and Output window at the bottom of the two. Here you could see database (created for demonstration) named prayogshala is connected on MySQL Server running on localhost. It has only one table named nbusers, which consists of attributes (username, firstname, lastname).

Blast from the Past,

I google’d a bit about the presence of NetBeans SQL Editor on Sun blogosphere and I was amazed to find a blog which dates back to Year 2005, when SQL Editor was first introduced into the NetBeans IDE. It was none other than, Geertjan Wielenga who blogged about it…

One area that’s improved significantly in NetBeans IDE 5.0 is the SQL Editor. In fact, there never was an SQL Editor before. In NetBeans IDE 4.1 — and the releases before that — you had a very small space where you could type SQL commands for sending to the database.

Also, you could read more about the SQL Editor and related features from “David Van Couvering’s blog”, Embedding of SQL Editor support into PHP Editor from the “NetBeans PHP Team’s blog”. Finally, don’t miss out on the award-winning plugin (PL/SQL Editor) created during NetBeans Innovator Grants.

This is in fact my 150th blog entry over here.
Indeed, its a special one!

Hmmm…

So, this was just a brief overview of the features currently supported by NetBeans IDE. The follow-up blogs will continue to focus on either some/all of these features in detail.

This blog has been contributed to NetBeans Community Docs Program and for latest updates on this content, refer to the contribution.

Stay tuned for more..

PHP to Javascript | Hyperlink Navigation

Wow, another surprise, did I miss something in release notes! I hunted again and again, I think I got the treasure first :P Actually, today I was again looking into PHP support, so thought of opening my first ever PHP application, I created using Dreamweaver 8, WAMPServer (which was actually my semester project) last December.

I was going through application’s index.php, which had embedded php scripts, and links to javascripts using following tags-

<script type="text/javascript" src="styles/some_script.js"></script>

where styles/some_script.js is the script used, along with 2 more scripts. So, in body tag, there was a call to one of the functions belonging to one of the three .js files, like-

<body onload="javascript:call_func();">

So, today I was thinking, it would be nice if I click on this function, and get directed to the javascript which has this function, started visualizing it. By mistake, I pressed CTRL (Windows users) and started hovering the mouse over “javascript:call_func();” I was shocked to see it actually detected a hyperlink, I clicked and another shock, it navigated me to the exact line where the function is defined in a particular javascript.

Amazing, isn’t it? Another cool discovery ;)

What are you upto? :)

Update on Issue #136216

Hey,

As I had mentioned in my previous blog entry about MySQL Admin and NetBeans. There, I had ended the post, with a note that I have filed an issue related to MySQL Server Node in Database Explorer.

After exchanging several mails and updating the bug report at Issuezilla. I told David, that I would be looking for a workaround, as he had set the TBD to 6.5 release. I can’t wait that long!

So, I had two options, either hack the code and fix it by myself, and use it. Else, I should look for a workaround.

I am glad that I could find a workaround for this issue. What I did, when I Stop Service using MySQL Admin Tool, run by clicking an option in the context-menu of the Server Node in Database Explorer. I should delete the Node from the Explorer, and then, Start Service using MySQL Admin Tool. Now, switch back to the IDE and click Connect in the context-menu of the Node. See, its that simple!

However, if you use it on a regular basis, it could really frustrate you. Anyways, if you can possibly hack into the code and fix it, do update the bug report, OR post a comment over here.

David has suggested another possible workaround, you could see in the Issuezilla, in my bug report. Also, this issue has now been given priority P2. Click on the link for more details.

Thanks for following! Hope you like the update from Issuezilla, as well as, from my previous blog.

Update 26th July-

Bug was fixed and I was notified long time back, though it was in trunk builds, and I don’t follow those. So, had to wait and meanwhile I forgot, until Patch 2 was applied and someone asked for verification last week, whether it works or not. I am glad it works!

Hope to see the same in NetCAT as well, will review soon!

eNjoy Technology…

This is being submitted for review to the blogging contest – Student Reviews NetBeans 6.1 and OpenSolaris!
Author – Varun Nischal, University - JIIT University

Add to Technorati Favorites

MySQL Admin and NetBeans

Hi,

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.
    1. You may either create option file on your own, OR you may copy some pre-defined option files, stored in MySQL Server extracted folder.
    2. 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 -
    1. TCP Port: 3306
    2. Base Directory: C:/Program Files/MySQL/mysql-5.0.51a-win32
    3. Data Directory: C:/Program Files/MySQL/mysql-5.0.51a-win32/data
    4. 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.

Firstly, you need a JDBC driver, as we are using Java to connect to MySQL databases, then you have to go for Connector/J (IV Type Driver), there are some more available for other languages too.

Here is a fantastic tutorial, which would enable you to get started with MySQL database management using NetBeans.

Connecting to a MySQL database

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.

eNjoy Technology…

This is being submitted for review to the blogging contest – Student Reviews NetBeans 6.1 and OpenSolaris!
Author – Varun Nischal, University - JIIT University

Add to Technorati Favorites