- Java EE 7 Development with NetBeans 8
- David R. Heffelfinger
- 681字
- 2025-02-28 12:20:46
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:
- First, we need to click on Window | Services.
- 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.
- Then we need to select the server to install from the list in the resulting window, and click on the button labeled Next>.
- We then need to enter a location in the filesystem where the application server is installed and click Next>.
- 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.
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.

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.