Sunday, September 19, 2010

Using NetBeans Database Tools

Many IDEs have the option of accessing the database and running commands in SQL. Besides this, these IDEs allow the operations to be done on the database, thus making everything at a single place (IDE), rather than switching between the DBMS and IDE continuously.

IBM RAD has this feature of Database Design, accessing databases, tables and schema from itself. Now let us look into the database access with the DBMS from NetBeans. We need to add a database connection before we do anything on the database in the IDE. For the database connection, add a new Driver in the "Drivers" node in the "Services" view (the one that is used for JDBC purposes. Add the JAR file that is used.).





The NetBeans IDE has 3 views on the left side of the main editor:
1. Projects,
2. Files and
3. Services.

Go to the Services view, right click on "Databases" node and select "New Connection".



Now a wizard pops up which asks you to enter the details of the Database connection and the Database. The JDBC URL is also shown in the last text box. Double check whether this database URL is correct or not.




After entering all the details correctly, click on OK and select the schema in the next wizard and click OK.




The Database is configured in NetBeans IDE. Make sure that the one you have added now is listed in the Databases node.




Now we can execute the SQL commands on the Database in NetBeans IDE. Right click on the Database and select "Execute Command".




As soon as you do this, the editor can be used for SQL statements. Enter the commands and see the results down under the editor. You have many buttons readily available and you can make use of all those things. Some of them are:
  1. Run SQL Button
  2. SQL History Button
  3. Inserting and Deleting rows in a table
  4. Truncating a table
  5. Committing changes
  6. Refreshing the results and so on.....



    An IDE has everything within it and all the IDEs are meant for productivity enhancement. But don't think that IDE does everything for you. It makes your life easy. Using IDE is not a crime especially after one gets some clear idea of a programming language. When you use an IDE to do a project, you are doing the project and not the IDE. Using Notepad is not always the best way to do things especially after a person is aware of the syntaxes in a programming language.
    Use IDEs to the fullest by knowing them to the fullest.
    Related Posts Plugin for WordPress, Blogger...