Reader small image

You're reading from  Java EE 7 Development with NetBeans 8

Product typeBook
Published inJan 2015
Reading LevelIntermediate
PublisherPackt
ISBN-139781783983520
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
David R Heffelfinger
David R Heffelfinger
author image
David R Heffelfinger

David Heffelfinger is the Chief Technology Officer of Ensode Technology, LLC, a software consulting firm based in the greater Washington DC area. He has been architecting, designing, and developing software professionally since 1995, and has been using Java as his primary programming language since 1996. He has worked on many large-scale projects for several clients including the US Department of Homeland Security, Freddie Mac, Fannie Mae, and the US Department of Defense. He also has a Masters degree in Software Engineering from Southern Methodist University. David is Editor-in-Chief of Ensode.net (http://www.ensode.net), a website about Java, Linux, and other technology topics.
Read more about David R Heffelfinger

Right arrow

Configuring NetBeans for Java EE development


NetBeans comes preconfigured with the GlassFish application server, and with the JavaDB RDBMS. If we wish to use the included GlassFish application server and JavaDB RDBMS, then there is nothing we need to do to configure NetBeans. We can, however, integrate NetBeans with other Java EE application servers such as JBoss/WildFly, WebLogic, or WebSphere and with other relational database systems such as MySQL, PostgreSQL, Oracle, or any RDBMS supported by JDBC, which pretty much means any RDBMS.

Integrating NetBeans with a third-party application server

Integrating NetBeans with an application server is very simple. To do so, we need to perform the following steps:

Note

In this section, we will illustrate how to integrate NetBeans with JBoss, the procedure is very similar for other application servers or servlet containers.

  1. First, we need to click on Window | Services.

  2. Next, we need to right-click on the node labeled Servers in the tree inside the Services window, and then select Add Server... from the resulting pop-up menu.

  3. Then we need to select the server to install from the list in the resulting window, and click on the button labeled Next>.

  4. We then need to enter a location in the filesystem where the application server is installed and click Next>.

  5. Finally, we need to select a domain, host, and port for our application server, then click on the Finish button.

The Services window should now display our newly added application server:

That's it! We have successfully integrated NetBeans with a third-party application server.

Integrating NetBeans with a third-party RDBMS

NetBeans comes with built-in integration with the JavaDB RDBMS system. Additionally, it comes with JDBC drivers for other RDBMS systems such as Oracle, MySQL, and PostgreSQL.

To integrate NetBeans with a third-party RDBMS, we need to tell NetBeans the location of its JDBC driver.

Note

In this section, we will create a connection to HSQLDB, an open source RDBMS written in Java, to illustrate how to integrate NetBeans with a third-party RDBMS; the procedure is very similar for other RDBMS systems such as Oracle, Sybase, SQL Server, among others.

Adding a JDBC driver to NetBeans

Before we can connect to a third-party RDBMS, we need to add its JDBC driver to NetBeans. To add the JDBC driver, we need to right-click on the Drivers node under the Databases node in the Services tab.

We then need to select a JAR file containing the JDBC driver for our RDBMS, NetBeans guesses the name of the driver class containing the JDBC driver. If more than one driver class is found in the JAR file, the correct one can be selected from the drop-down menu labeled Driver Class. We need to click on the OK button to add the driver to NetBeans as shown in the following screenshot:

Once we have followed the preceding procedure, our new JDBC driver is displayed in the list of registered drivers.

Connecting to a third-party RDBMS

Once we have added the JDBC driver for our RDBMS into NetBeans, we are ready to connect to the third-party RDBMS.

To connect to our third-party RDBMS, we need to right-click on its driver under the Services tab, then click on Connect Using... on the resulting pop-up menu as shown in the following screenshot:

Then we need to enter the JDBC URL, username, and password for our database.

After clicking on the Next> button, NetBeans will ask us to select a database schema. In this case, we select PUBLIC from the drop-down menu.

In the next step in the wizard, we are allowed to enter a user-friendly name for our database connection, or we can simply accept the default value.

After clicking on the Finish button, our database is shown in the list of databases in the Services window. We can connect to it by right-clicking on it, selecting Connect from the resulting pop-up menu, then entering our username and password for the database (if we chose not to allow NetBeans to remember the password when we added the database).

We have now successfully connected NetBeans to a third party RDBMS.

Previous PageNext Page
You have been reading a chapter from
Java EE 7 Development with NetBeans 8
Published in: Jan 2015Publisher: PacktISBN-13: 9781783983520
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
David R Heffelfinger

David Heffelfinger is the Chief Technology Officer of Ensode Technology, LLC, a software consulting firm based in the greater Washington DC area. He has been architecting, designing, and developing software professionally since 1995, and has been using Java as his primary programming language since 1996. He has worked on many large-scale projects for several clients including the US Department of Homeland Security, Freddie Mac, Fannie Mae, and the US Department of Defense. He also has a Masters degree in Software Engineering from Southern Methodist University. David is Editor-in-Chief of Ensode.net (http://www.ensode.net), a website about Java, Linux, and other technology topics.
Read more about David R Heffelfinger