1) In the NetBeans IDE with our project opened, open the Services window.
2) Right-click on the Databases folder and select the New Connection item.
3) In the opened New Connection Wizard, click the dropdown arrow in the Driver combo box, and select the Oracle Thin item, since we installed this kind of driver.
4) Click on the Add button and browse to our JDBC driver, ojdbc8.jar, which is located in the folder C:\Temp. Refer to Appendix H to get more details about this location. Select this driver and click on the Open button to return to the New JDBC Driver wizard. Click on the Next button to continue.
FIGURE 8.85 The retrieved new faculty record.
5) In the opened New Connection Wizard, all other connection parameters, including the Host, Port and Service ID, have been setup by the system, and the only parameters you need to enter are username and password. Enter them into the related boxes as shown:
a. User Name:
b. Password:
CSE _ DEPT
oracle _ 18c
Your finished New Connection Wizard should match the one shown in Figure 8.86.
Pay special attention to the content in the JDBC URL box, which is our completed connec-tion URL, and click on the Test Connection button to make and check this connection. A Connection Succeeded message is displayed if this connection is successful.
Click on the Next button to select the database schema. Keep the default schema, CSE _ DEPT, as the schema, and click on the Next button.
Modify the connection name by cutting off the attached [CSE _ DEPT on Default schema] to get our final Input connection name as: jdbc:oracle:thin:@localhost:1521:XE, and click on the Finish button to complete the database connection.
Now that our database is connected, we can open it to check our data insertion. In the opened Services window, expand each of the following folders:
1) Our database connection URL
2) Our database, CSE _ DEPT
3) The Tables folder
Now right-click on our Faculty Table and select the View Data item to open this Table. The opened Faculty Table is shown in Figure 8.87.
FIGURE 8.86 The finished New Connection Wizard.
FIGURE 8.87 The opened Faculty Table with the new inserted faculty record.
The new inserted faculty member, Susan Bai, has been inserted at the bottom of this Table, and this record is highlighted in Figure 8.87. Our data insertion using JavaServer Pages and Java beans is successful! To keep our database clean and neat, it is generally recommended to delete this new faculty member from the Faculty Table. However, we will to keep it right now since we can test the data delete action by using this record in the next section.
A complete Web application project, JavaWebOracleInsert, which contains the LogIn.jsp, Selection.jsp, Faculty.jsp, FacultyProcess.jsp, FacultyQuery.jsp and FacultyInsertBean.java files, can be found in the folder Class DB Projects\Chapter 8 in the Students folder on the CRC Press ftp site (refer to Figure 1.2 in Chapter 1).