-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Java EE 7 Development with NetBeans 8
By :

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 an application server is very simple. To do so, we need to perform the following steps:
In this section, we will illustrate how to integrate NetBeans with JBoss, the procedure is very similar for other application servers or servlet containers.
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.
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.
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.
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.