Using SQL Editor in NetBeans IDE

Contributed By; Varun Nischal

[[{TableOfContentsTitle=Contents} | {TableOfContents title='Contents'}]]

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


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 (File:sqleditor-run-sql-button_UsingSQLEditorInNetBeans.png), 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.


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;


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.


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.

Reposted from this blog entry;

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo