Connecting to Oracle Database From NetBeans IDE

April 2, 2018 | Author: GiovanniBanegas | Category: Sql, Database Index, Databases, Net Beans, Oracle Database


Comments



Description

Connecting to Oracle Database from NetBeans IDENetBeans IDE includes built-in support for Oracle Database. You can easily establish a connection from inside the IDE and begin working with the database. This tutorial demonstrates how to use a local installation of Oracle Database 10g Express Edition (Oracle Database XE), a lightweight database that is free to develop, deploy, and distribute. This document shows how to set up a connection to a local installation of Oracle Database XE from the NetBeans IDE, use the IDE's built-in SQL editor to handle the database data, and how to enable the OCI 8 PHP extension to write PHP code that connects to an Oracle database. To follow this tutorial, you need the following software and resources. Software or Resource NetBeans IDE Version Required 7.2, 7.3, 7.4, 8.0, Java EE bundle Java Development Kit (JDK) Version 7 or 8 Oracle Database XE 10 g Express Edition Oracle JDBC driver ojdbc6.jar Before You Begin Before you start walking through this tutorial, consider the following:   This tutorial demonstrates how to connect to an Oracle Database XE instance installed on your local system, but the steps can also be applied when you are connecting to a remote instance. If you are connecting to a local instance you need to download and install Oracle Database XE. The installation process is simple and intuitive, but if you have questions, refer to the Oracle Database XE installation guide for your platform. There are two categories of Oracle JDBC drivers: OCI and JDBC Thin. o Oracle's JDBC Thin driver is based on Java and is platform independent. This standalone driver does not require the presence of other Oracle libraries and allows a direct connection to an Oracle Database. This tutorial uses this driver to show how to connect to Oracle Database. Before walking through the tutorial, you need to download the ojdbc6.jar file and save it on your system. Note for Windows users: Windows may change the extension of the downloaded file from .jar to .zip. It is still a .jar file, however. You can rename the file to .jar. o  Oracle's OCI driver uses Oracle's native client libraries to communicate with databases. These libraries are obtained as part of the Oracle Instant Client. Although the Thin driver is sufficient in most cases, you might also want to use the OCI driver by following the steps in Using OCI JDBC Driver with the NetBeans IDE. A good example of the OCI driver use is accessing a remote Oracle database from a PHP application using the Oracle Instant Client libraries. See the OCI 8 and the NetBeans IDE for PHP section in this tutorial for information on how to enable the OCI8 extension for PHP. If you have not used Oracle Database XE before, take the Oracle Database XE Getting Started tutorial. Warning for GlassFish Users: The Oracle Database XE homepage, which you use to administer the database, uses port 8080 by default. Oracle GlassFish Application Server also uses port 8080 by default. If you run both programs at the same time, Oracle Database XE blocks browsers from accessing GlassFish at localhost:8080. All applications deployed on GlassFish return 404 in this case. The simple solution is to shut down Oracle Database XE if you do not need it when you are running GlassFish. If you need to run both at the same time, change the default port that Oracle Database XE uses. This is easier than changing the GlassFish default port. There are many sets of instructions on the Internet for changing the Oracle Database XE default port, including one in Oracle forums. Establishing a Connection to Oracle Database In this exercise you will test and create a new connection to the database. 1. Start the Oracle database. 2. Open the Services window (Window > Services or Ctrl-5;⌘-5 on Mac). In the Services window, right-click the Databases node and choose New Connection. 3. In the New Connection wizard, select Oracle Thin in the Driver dropdown list. 4. Click Add and locate the ojdbc6.jar file that you previously downloaded. Click Next. 5. In the Customize Connection panel of the wizard, enter the following values and click Next. Value Name Driver Name Oracle Thin (with Service ID (SID)) Host localhost or 127.0.0.1. Note: In the case of a remote connection, provide the IP address or resolvable hostname of the machine where the database is installed. Port 1521 (default) Service ID (SID) XE (default SID for Oracle Database XE). Note: If you are connecting to a remote database, ask the database administrator to provide you with the database SID. Username Password Enter the username. For the purpose of our tutorial, enter system (the default database administrator account) and password that you used during database installation. Enter the password for the selected username. 6. Click Test Connection to confirm that the IDE is able to connect to the database. Click Next. If the attempt is successful, the message "Connection succeeded" is displayed in the wizard. 7. Select HR in the Select Schema dropdown list. Click Finish. Note: You need to unlock the HR schema before you can access it in NetBeans. Unlocking the HR database is described in the Oracle Database XE Getting Started tutorial. The new connection will appear under the Databases node in the Services window. You can expand it and start browsing the database object's structure. Change the display name for the connection node: choose Properties from the node's popup menu and click the ellipsis button for the Display Name property. Enter OracleDB as the Display Name and click OK. Note. Although the steps above demonstrate the case of connecting to a local database instance, the steps for connecting to a remote database are the same. The only difference is that instead of specifying localhost as the hostname, enter the IP address or hostname of the remote machine where Oracle Database is installed. Manipulating Data in Oracle Database A common way of interacting with databases is running SQL commands in an SQL editor or by using database management interfaces. For example, Oracle Database XE has a browser-based interface through which you can administer the database, manage database objects, and manipulate data. Although you can perform most of the database-related tasks through the Oracle Database management interface, in this tutorial we demonstrate how you can make use of the SQL Editor in the NetBeans IDE to perform some of these tasks. The following exercises demonstrate how to create a new user, quickly recreate a table, and copy the table data. Creating a User Let's create a new database user account to manipulate tables and data in the database. To create a new user, you must be logged in under a database administrator account, in our case, the default system account created during database installation. 1. In the Services window, right-click the OracleDB connection node and choose Execute Command. This opens the NetBeans IDE's SQL editor, in which you can enter SQL commands that will be sent to the database. 2. To create a new user, enter the following command in the SQL Editor window and click the Run SQL button on the toolbar. create user jim identified by mypassword default tablespace users temporary tablespace temp quota unlimited on users; This command creates a new user jim with the password mypassword. The default tablespace is users and the allocated space is unlimited. 3. The next step is to grant the jim user account privileges to do actions in the database. We need to allow the user to connect to the database, create and modify tables in user's default tablespace, and access the Employees table in the sample hr database. In real life, a database administrator creates custom roles and fine tunes privileges for each role. However, for the purpose of our tutorial, we can use a predefined role, such as CONNECT. For more information about roles and privileges, see Oracle Database Security Guide. grant connect to jim; grant create table to jim; grant select on hr.departments to jim; Tablespaces in Oracle Databases A tablespace is a logical database storage unit of any Oracle database. In fact, all of the database's data is stored in tablespaces. You create tables within allocated tablespaces. If a default tablespace is not explicitly assigned to a user, the system tablespace is used by default (it is better to avoid this situation) Creating a Table There are several ways to create a table in the database through the NetBeans IDE. For example, you can run an SQL file (right-click the file and choose Run File), execute an SQL Command (right-click the connection node and choose Execute Command) or use the Create Table dialog box (right-click the Tables node and choose Create Table). In this exercise you will recreate a table by using the structure of another table. In this example, you want the user jim to create a copy of the Departments table in his schema by recreating the table from the hr database. Before you create the table you will need to disconnect from the server and log in as user jim. 1. Right-click the OracleDB connection node in the Services window and choose Disconnect. 2. Right-click the OracleDB connection node and choose Connect and log in as jim. 3. Expand the Tables node under the HR schema and confirm that only the Departments table is accessible to user jim. When you created the user jim, the Select privilege was limited to the Departments table. Save the . 3. 2. the new DEPARTMENTS table is created and appears under the JIM schema node. 6. To enter the data manually. Column DEPARTMENT_ID Value 10 . Point to the . For example. Click the Insert Records icon on the View Data toolbar and to open the Insert Record window. Click OK. If you want to copy the data from the original Departments table to the new table.grab file that you created. Expand the JIM schema.4. When you click OK. Right-click the Departments table node and select Grab Structure. you can enter the following values taken from the original DEPARTMENTS table. perform the following steps. Type in the fields to enter the data. you can enter the data manually in the table editor or run an SQL script on the new table to populate the table. Review the SQL script that will be used to create the table. If you right-click the table node and choose View Data you will see that the table is empty. Right-click the DEPARTMENTS table under the JIM schema and choose View Data. Click OK.grab file on your disk. 5. 1. right-click the Tables node and choose Recreate Table. 1700). Enter the script in the SQL Command tab. we will simply run the ready-to-use SQL file in the IDE: 1. perform the following steps. To open the Favorites window. 2. DEPARTMENT_NAME. At first. The following script will populate the first row of the new table with the data from the original table. Right-click the DEPARTMENTS table under the HR schema and choose View Data. 4. 1. Working with Table Data To work with table data.sql file and choose Run File. 200. 2. MANAGER_ID. Select all rows in the View Data window. you can add. 1. Note. In the Services window. By running SQL queries.sql file. 3. the IDE might prompt you to select the correct connection. LOCATION_ID) VALUES (10. right-click the Tables node and choose Refresh in the popup menu. You can then copy the script and modify it as necessary to insert the data in your table. create the second table named Locations in the jim schema (stay logged under the jim's user account).DEPARTMENT_NAME Administration MANAGER_ID 200 LOCATION_ID 1700 To populate the table using an SQL script. Right-click the DEPARTMENTS table under the JIM schema and choose Execute Command. You can see that the Locations table with data was added to the JIM schema. Open the Favorites window of the IDE and locate the locations. then right-click in the table and choose Show SQL Script for INSERT from the popup menu to open the Show SQL dialog that contains the script.DEPARTMENTS (DEPARTMENT_ID. Click the Run button in the toolbar. If more than one database connection is registered with the IDE. This time.sql file to the USER_HOME directory on your computer. INSERT INTO JIM. click Window > Favorites in the main menu (press Ctrl-3). 'Administration'. modify and delete data maintained in database structures. The USER_HOME directory is listed in the Favorites window by default. You can retrieve the SQL script for populating the table from the original table by performing the following steps. Download and save the locations. Right-click the locations. you can make use of the SQL Editor in NetBeans IDE. 2. . . This SQL query returns the rows from the Departments table whose location_id values are equal to the values in the matching column in the Locations table. LOCATION_ID. we run a query to display information from two tables: Departments and Locations. enter the following SQL statement. STATE_PROVINCE FROM departments NATURAL JOIN locations ORDER by DEPARTMENT_NAME. 6. This join selects only the rows that have equal values in the matching location_id column. You will see the contents of the Locations table. You can insert new records and modify existing data directly in this view window. Next. SELECT DEPARTMENT_NAME. Open the SQL Command window (right-click the Tables node under the JIM schema and choose Execute Command). as you could do in the representation of a single table. POSTAL_CODE. CITY. because both tables have the same "location_id" column that holds values of the same data type. we will use a simple "natural join". STREET_ADDRESS.5. and click the Run SQL icon. with the results being ordered by the Department name. In our case. MANAGER_ID. Note that you cannot insert new records directly in the results of this query. Right-click the Locations table node and choose View Data to see the table contents. 3. If you successfully enabled OCI 8. Run SQL Statements. Run phpinfo(). click the Insert Records icon and insert new data in the Insert Records window that opens. You can log in under the system account. Only one of these extensions can be enabled at one time.dll (for Oracle 11g) or extension=php_oci8. The table will be automatically updated with the new records. GUI View of Database Tables. For this.dll (for Oracle 10.9 installed to the root directory of C:. Keep Prior Tabs. Click the Show SQL button to see the SQL code for this operation. Click the Keep Prior Tabs icon on the SQL Editor toolbar to keep the windows with the results of previous queries open. 3. This can be helpful if you want to compare the results of several queries. Restart Apache. select it and click the Delete Selected Records icon. the modified text is shown in green. Note that NetBeans IDE supports only PHP 5.2 or 5. If there is no OCI 8 extension file in your extensions folder. double-click directly inside any cell in the GUI View of a table and type the new value. This directory is usually PHP_HOME/ext. click the Run SQL icon. 4. To use NetBeans IDE for PHP and an Oracle database: 1. Important: If there is no such line in php. For example. . You can also add. you already used the capabilities of the NetBeans IDE SQL Editor. When OCI 8 is enabled. SQL History (Ctrl-Alt-Shift-H). OCI 8 and the NetBeans IDE for PHP You can use the OCI 8 PHP extension and the NetBeans IDE for PHP to write PHP code that communicates with an Oracle database. If you have several database connections and you need to quickly switch between them in the SQL Editor. with PHP 5. the database user should be granted the privilege to Create View that our sample user does not have.2 or XE).2.ini file in an editor. find the SQL statement that you need and click Insert to place the statement to the SQL Command window. Open your php.9\ext". o To modify a record. click the Cancel Edits icon. o To delete a row. 5. right-click the selection and choose Run Selection. see Installing PHP and the Oracle Instant Client for Linux and Windows for information about downloading and installing OCI 8. and delete table data directly in this view. 4. If you want to run only a part of SQL.) 5. 1. o To add a record. NetBeans IDE for PHP accesses this extension for code completion and debugging. 2. use the Connections drop-down list. grant jim the Create View privilege (with this SQL statement: "grant create view to jim.ini. (Windows users should restart their computer. the extension_dir setting should be extension_dir="C:\php-5. Until the change is committed. Make certain that the extension_dir property is set to the PHP extensions directory. Choose the connection from the drop-down list. Use the SQL History icon on the SQL Editor toolbar to view all SQL statements that you ran for each of the database connections. Locate and uncomment the line extension=php_oci8_11g. When you right-click a table node in the Services window and choose View Data. 2. To cancel changes. Connection list. 3. click the Commit Changes icon. look in the extensions folder for the OCI 8 extension file. Here we list several other capabilities of the NetBeans IDE SQL Editor that might be useful to you.") and try creating your own view.You can save the SQL join query as a View (right-click the View node and choose Create View) and run it conveniently whenever you want. To run the entire statement that is currently in the SQL Command window. To commit your changes.2. only the selected part will be executed. Set up the PHP environment as described in the Configuring Your Environment for PHP Development section of the PHP Learning Trail. select it in the SQL Command window. the IDE displays a visual representation of the table and its data (as shown in the figure above). modify. Tips for Working in the NetBeans IDE SQL Editor If you were following this tutorial. In this case. an OCI 8 section appears in phpinfo() output. If your question is not answered here. provide the connection details: IP address. SID. . make your own search or use the Send Feedback on This Tutorial link to provide constructive feedback. Download the "Basic" package of Oracle Database Instant Client for your platform. if you want to use both applications at the same time.jdbc. Troubleshooting The troubleshooting tips below describe only a few exceptions that we met. Follow the installation instructions on this page. To reset the default port of the Oracle Database. Notice the difference in the JDBC URL for the OCI and Thin drivers. you need to change this default port of one of them.jdbc. 4. 2. The selection of which driver to use depends on the interface: oracle. because it contains all the libraries required for the OCI driver to communicate with the database. In the IDE's Services window.v3.services.monitor. 3. port.OracleDriver for the Thin driver and oracle. you must also install the Oracle Database Instant Client.   You see the error similar to the following: Shutting down v3 due to startup exception : No free port within range: >> 8080=com. username and password. In the Customize Connection dialog box. choose Oracle OCI.sun. click Add and specify the ojdbc6.Using OCI JDBC Driver with the NetBeans IDE OCI driver packages are available in the same JAR file as the JDBC Thin driver (ojdbc6. right-click the Databases node and choose New Connection. So.enterprise.jar).SETHTTPPORT(<new port number>). To connect to Oracle Database from the NetBeans IDE by using the Oracle's OCI driver: 1.MonitorableSelectorHandler@7dedad This happens because both the GlassFish application server and Oracle Database use port 8080. you can use this command: CONNECT SYSTEM/password EXEC DBMS_XDB.impl. In the Locate Driver step.driver.jar file.OracleDriver for the OCI driver. To use the OCI driver. 7. you can begin working with the database in the IDE. Or the SID is incorrect or not known to the listener. If this is your case. .  You receive the following error: ORA-12705: Cannot access NLS data files or invalid environment specified.0. For Windows. this problem is unlikely to appear. and fully supports SQL. the default SID is XE). The Java DB database is Sun's supported distribution of Apache Derby. In a general case. Java DB is a fully transactional. the file is at %ORACLE_HOME%\network\admin\tnsnames. standards-based database server. 7. you can skip ahead to Starting the Server and Creating a Database. If you use a default SID (e. For Linux/Unix.ora). written entirely in Java. To follow this tutorial. run the command "unset NLS_LANG" Working with the Java DB (Derby) Database This document demonstrates how to set up a connection to Java DB database in NetBeans IDE. consult the official documentation. see Registering a GlassFish Server Instance in the IDE's Help Contents (F1). and is included in JDK 6 as well. Therefore. If you are using Mac OS X you can download and install Java DB manually or use the Java DB that is installed by Java EE version of the NetBeans IDE installer.x. it might occur if Oracle Database has not been started (simplest case). the invalid NLS_LANG settings should be disabled at your operating system level. this means that the NLS_LANG environment variable contains an invalid value for language. You receive the following error: Listener refused the connection with the following error: ORA-12505. If you just downloaded Java DB on its own.ora file (on a Windows machine. 10. for Oracle Database Express Edition.5. There are a number of causes for this exception. Configuring the Database If you have the GlassFish Server registered in your NetBeans IDE installation.x Note.2. or character set. TNS:listener does not currently know of SID given in connect descriptor. Once a connection is made.4. JDBC API. run SQL statements and queries. perform the following steps. you need the following software and resources. The Java DB database is packaged with the GlassFish application server. 8.3. and more. Java EE Java Development Kit (JDK) Version 7 or 8 Java DB version 10. This happens when the Service ID (SID) of the database instance provided by the connect descriptor is not known to the listener. For more information on Java DB database.g. and Java EE technology.4. Java DB will already be registered for you. For example. Software or Resource Version Required NetBeans IDE 7. allowing you to create tables. The SID is included in the CONNECT DATA parts in the tnsnames. rename the NLS_LANG subkey in your Windows registry at \HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE.  Java DB is installed when you install JDK 7 or JDK 8 (except on Mac OS X). If you downloaded the GlassFish server separately and need help registering it in NetBeans IDE. secure. populate them with data. territory. enter the path to the Java DB root directory (javadb) that you specified in the previous step. it is important to understand the components found in Java DB's root directory:      The demo subdirectory contains the demonstration programs. as well as register database servers in the IDE (as demonstrated in the previous step). Type contact for the Database Name. you can create this folder in the Java DB root directory (javadb) or in any other location. Note the following output in the Output window. The docs subdirectory contains the Java DB documentation. Registering the Database in NetBeans IDE Now that the database is configured.netbeans-derby on a Windows machine. Right-click the Java DB node and choose Create Database to open the Create Java DB Database dialog. Click OK For example. 1. . This contextual menu items allow you to start and stop the database server. The javadoc subdirectory contains the API documentation that was generated from source code comments. Before continuing further. use the default location if a location is already provided. If you just downloaded Java DB and want to have the database server reside in a different location than where it was extracted to. A folder named 'javadb' will be created in the same location as the file. If the Database Location field is empty you will need to set the path to the directory that contains your databases. On your system. In the Services window. right-click the Java DB Database node and choose Properties to open the Java DB Settings dialog box.1. For example. 3. 2. The lib subdirectory contains the Java DB jar files. the default location might look like C:\Documents and Settings\username\. right-click the Java DB node and choose Start Server. create a new database instance. To start the database server: 1. For Database Location. The bin subdirectory contains the scripts for executing utilities and setting up the environment. Run the self-extracting file. 3. In the Services window. 2. For the Java DB Installation text field. you should relocate it now. Starting the Server and Creating a Database The Java DB Database menu options are displayed when you right-click the Java DB node in the Services window. Note. You will need to create a directory for the databases if no directory exists. create a new directory to be used as a home directory for the individual instances of the database server. indicating that the server has started: 2. perform the following steps to register Java DB in the IDE. Note. The database connection node( ) is displayed under the Databases node.4. Type nbuser for the User Name and Password. You will also see the sample [app on APP] database connection that is the default database schema. Connecting to the Database So far.     creating. you have successfully started the the database server and created a database instance named contact in the IDE. modifying tables populating tables with data viewing tabular data executing SQL statements and queries In order to begin working with the contact database. if you expand the Databases node in the Services window you can see that the IDE created a database connection and that the database was added to the list under the Java DB node. you need to create a connection to it. 1. Expand the Databases node in the Services window and locate the new database and the database connection nodes. The Database Location is the default location set during installation of Java DB from GlassFish. Click OK. this location might be different. To connect to the contact database perform the following steps. . deleting. Note. After you create the database. If you installed Java DB separately. In the Services window of the IDE you can perform the following common tasks on database structures. The name of the database is displayed under the Java DB node. In NetBeans IDE you can add a database table by either using the Create Table dialog. For Column Name. Because all rows must be identified. Right-click the APP node and choose Set as Default Schema. Create a convenient display name for the database by right-clicking the database connection node (jdbc:derby://localhost:1527/contact [nbuser on NBUSER]) and choosing Rename. It does not yet contain any tables or data. primary keys cannot contain a Null value. Expand the Contact DB connection node and note that there are several schema subnodes. You are creating a table named FRIENDS that holds the following data for each contact record: . select the Primary Key checkbox to specify that this column is the primary key for your table. Creating Tables The contact database that you just created is currently empty. or by inputting an SQL statement and running it directly from the SQL Editor. Note that when you select the Primary Key check box. Repeat this procedure now by specifying fields as shown in the table below: Key Index [checked] [checked] Null [checked] [checked] [checked] [checked] [checked] Unique Column name [checked] id firstName lastName nickName friendSince email Data type INTEGER VARCHAR VARCHAR VARCHAR DATE VARCHAR Size 0 20 20 30 0 60 8. The Add Column dialog box appears. 4. signifying that the connection was successful. select INTEGER from the drop-down list. You can explore both methods:   Using the Create Table Dialog Using the SQL Editor Using the Create Table Dialog 1. Right-click the Tables node and choose Create Table to open the Create Table dialog box. Type Contact DB in the text field and click OK. Views and Procedures. 5. enter id. 6.2. All tables found in relational databases must contain a primary key. and by default are used as the table index. The connection node icon appears whole ( ). For Data Type. Expand the APP node and note that there are three subfolders: Tables. Right-click the contact database connection node (jdbc:derby://localhost:1527/contact [nbuser on NBUSER]) and choose Connect. type FRIENDS. 7. This is because primary keys are used to identify a unique row in the database. The app schema is the only schema that applies to this tutorial. the Index and Unique check boxes are also automatically selected and the Null check box is deselected. 3. Under Constraints. Click Add Column. 2. In the Table Name text field. 3. CREATE TABLE "COLLEAGUES" ( 4. 5. "LASTNAME" VARCHAR(30). and you can see a new FRIENDS table node ( ) display under the Tables node. "TITLE" VARCHAR(10). either right-click the Contact DB connection node or the Tables node beneath it and choose Execute Command. In the Service window. 7. SQL adheres to strict syntax rules which you should be familiar with when working in the IDE's editor. "ID" INTEGER not null primary key. This is a table definition for the COLLEAGUES table you are about to create: 3. "FIRSTNAME" VARCHAR(30). "DEPARTMENT" VARCHAR(20). 2. 9. "EMAIL" VARCHAR(60) ). 8. When you are sure that your Create Table dialog contains the same specifications as those shown above. A blank canvas opens in the SQL Editor in the main window. 6. Beneath the table node the columns (fields) are listed. The IDE generates the FRIENDS table in the database. Note: Statements and queries formed in the SQL Editor are parsed in Structured Query Language. SQL syntax can also . Enter the following query in the SQL Editor. click OK. Using the SQL Editor: 1.o o o o o First Name Last Name Nick Name Friend Since Date Email Address 9. starting with the primary key ( ). Click the Run SQL ( ) button in the task bar at the top of the editor (Ctrl-Shift-E) to execute the query. right-click the Contact DB connection node in the Services window and choose Refresh. There are several ways that you can add records to your table. Running an SQL Statement 1.FRIENDS VALUES (1. a message displays indicating that the statement was successfully executed. Expand the Tables under the Contact DB node in the Services window. When you choose View Data.    Write an SQL statement in the SQL Editor that supplies a value for every field present in the table schema. In this case. Read the sections below to learn how to use all these methods of populating the FRIENDS table with data. Use the SQL Editor to add records to the table.'2004-12-25'. Note that a new row has been added with the data you just supplied from the SQL statement.'Theodore'. you can use the SQL Editor code completion. a query to select all the data from the table is automatically generated in the upper pane of the SQL Editor. The results of the statement are displayed in the lower pane of the SQL Editor. To verify that the new record has been added to the FRIENDS table. In the SQL Editor. Using the SQL Editor . This updates the Runtime UI component to the current status of the specified database. The Output window displays a message indicating that the statement was successfully executed. 3. In the Output window (Ctrl-4). you can start populating it with data. 4. 10. Right-click inside the SQL Editor and choose Run Statement. INSERT INTO APP. 11. Use an external SQL script to import records to the table. right-click the FRIENDS table node in the Services window and choose View Data. 2. To verify changes. See the JavaDB Reference Manual for specific guidelines.com') While you are typing. right-click the FRIENDS table and choose Execute Command to open the SQL Editor window.'Bagwell'.'tbag@foxriver. This step is necessary when running queries from the SQL Editor in NetBeans IDE. ) now Adding Table Data Now that you have created one or more tables in the contact database. the FRIENDS table displays in the lower pane. enter the following statement.differ depending on the database management system. Note that the new COLLEAGUES table node ( displays under Tables in the Services window.'T-Bag'. Deleting Tables In the following step. The script automatically opens in the SQL Editor. Choose File > Open File from the IDE's main menu. 3. you can choose a date from the calendar. Click in each cell and enter records. you just created a COLLEAGUES table in the Using the SQL Editor section above. Alternatively. you can copy the contents of colleagues. 1. To delete a database table perform the following steps. Note that for the cells with Date data type. In the SQL Editor. and want to import it into NetBeans IDE to run it on a specified database. Right-click the FRIENDS table node and choose View Data (if you have not done this at the last step of the previous section). Using an External SQL Script Issuing commands from an external SQL script is a popular way to manage your database. 1. The Insert Records dialog box appears. Expand the Tables node under the database connection node in the Services window. modify and delete existing records. 2.1. In this exercise the script will create a new table named COLLEAGUES and populate it with data. Perform the following steps to run the script on the contact database. . you can sort the results by clicking on a row header. you can delete the already created COLLEAGUES table now. In the file browser navigate to the location of the saved colleagues. 2. However.sql to your local system 2. Click OK when you are done. and see the SQL script for the actions you are doing in the editor (the Show SQL Script command from the pop-up menu). 3. Download colleagues. Right-click the table that you want to delete and choose Delete. you use an external SQL script to create a new COLLEAGUES table. In order to make it clear that the SQL script indeed creates a new table. Make sure your connection to Contact DB is selected from the Connection drop-down box in the tool bar at the top of the editor. You may have already created an SQL script elsewhere.sql file and click Open.sql and then open the SQL editor and paste the contents of the file into the SQL editor. Click the Insert Record(s) (Alt-I) button to add a row. Expand the Tables node under the sample database connection. you can also compare the tabular data with the data contained in the SQL script to see that they match. Expand the APP schema node under the Contact DB database connection. use the sample database that comes packaged with Java DB. navigate to the location where you saved the CUSTOMER grab file and click Open to open the Name the Table dialog box. In this manner. Click Save. specify a location on your computer to save the grab file that will be created. similar to what was described at the beginning of this tutorial. 5. then you can recreate the table in your chosen database: 1. Note that the new COLLEAGUES table from the SQL script now displays as a table node under contact in the Services window. The script is executed against the selected database. Click the Run SQL ( ) button in the SQL Editor's task bar. 3. Connect to the sample database by right-clicking the connection node under the Databases node in the Services window and choosing Connect (username and password is app). the IDE offers a handy tool for this. The grab file records the table definition of the selected table. right-click the COLLEAGUES table and choose View Data. To verify changes. You first need to have the second database registered in the IDE. 6. For the purposes of this tutorial. Recreating Tables from a Different Database If you have a table from another database which you would like to recreate in the database you are working in from NetBeans IDE. 2. 5. 4. right-click the Tables node and choose Recreate Table to open the Recreate Table dialog box. .4. In the Grab Table dialog that opens. This process is essentially carried out in two parts: You first 'grab' the table definition of the selected table. right-click the CUSTOMER table node and choose Grab Structure. To view the data contained in the new tables. and any feedback is generated in the Output window. In the Recreate Table dialog box. right-click the Contact DB connection node in the Services window and choose Refresh. 6. or Structured Query Language. you need the following software and resources. click OK to immediately create the table in the contact database. At this point you can change the table name or edit the table definition. To follow this tutorial. 7. If you view the data in the new CUSTOMER table you will see that there are no records in the database. flexibility and reliability. MySQL employs SQL. A new CUSTOMER table node appears beneath the Contact DB connection node. Once connected.3. MySQL is a popular Open Source relational database management system (RDBMS) commonly used in web applications due to its speed. populating tables with data. for accessing and processing data contained in databases. This tutorial is designed for beginners with a basic understanding of database management. Software or Resource NetBeans IDE Version Required 7. 7. and running SQL queries on database structures and content. but that the structure of the table is identical to the table that you grabbed Connecting to a MySQL Database This document demonstrates how to set up a connection to a MySQL database from the NetBeans IDE.0.2.4. 8. you can begin working with MySQL in the IDE's Database Explorer by creating new databases and tables. Otherwise. Java . who want to apply their knowledge to working with MySQL in NetBeans IDE. Type any arguments for the admin tool in the Arguments field. In the Path/URL to admin tool field. Configuring MySQL Server Properties NetBeans IDE comes bundled with support for the MySQL RDBMS. To find the start command. Note: mysqladmin is the MySQL admin tool found in the bin folder of the MySQL installation directory. The start command may also vary if MySQL was installed as part of an AMP installation. you must configure the MySQL Server properties. 5. Enter the Administrator password. 4. Enter the Administrator user name (if not displayed). type or browse to the location of the MySQL start command. or other web-based administration tools. PhpMyAdmin. It is a command-line tool and not ideal for use with the IDE. 3. Note: A blank password can also be a password. 7. Before you can access the MySQL Database Server in NetBeans IDE. 2. Type any arguments for the start command in the Arguments field. Notice that the IDE enters localhost as the default server host name and 3306 as the default server port number.Java Development Kit (JDK) Version 7 or 8 MySQL database server version 5. please refer to the official MySQL documentation for help. 1. You can also refer to Setting Up the MySQL Database Server in the Windows Operating System. Right-click the Databases node in the Services window and choose Register MySQL Server to open the MySQL Server Properties dialog box. allowing you to enter information for controlling the MySQL Server. . Note: The recommended binary for Unix and NetWare is mysql_safe. 6. Confirm that the server host name and port are correct. type or browse to the location of your MySQL Administration application such as the MySQL Admin Tool. Note: You need administrative access to be able to create and remove databases. look for mysqld in the bin folder of the MySQL installation directory. In the Path to start command. If you are installing for the first time. The default is set to blank. The Admin Properties tab is then displayed. Click the Admin Properties tab at the top of the dialog box.x Note: This tutorial assumes that you already have the MySQL RDBMS installed and configured on your computer. type -u root stop to grant root permissions for stopping the server. in the Arguments field. When the server is connected you will be able to expand the MySQL Server node and view the all available MySQL databases. To connect to the database server. If you are satified with your configuration. You might be prompted to supply a password to connect to the server. create an instance called MyNewDatabase: . For purposes of this tutorial. the Admin Properties tab should resemble the following figure. In the Path to stop command field. click OK. Starting the MySQL Server Before you can connect to a MySQL Database Server. Now that you are connected to the MySQL server. you must first ensure that the MySQL Database Server is running on your machine. 9. When finished. The SQL Editor is generally accessible via the Execute Command option from the right-click menu of the connection node (or of the connection node's child nodes). Creating and Connecting to the Database Instance A common way of interacting with databases is through an SQL editor. confirm that the MySQL Database Server is running on your machine. If the command is mysqladmin. type or browse to the location of the MySQL stop command. right-click the Databases > MySQL Server node in the Services window and choose Connect. NetBeans IDE has a built-in SQL Editor for this purpose. This is usually the path to mysqladmin in the bin folder of the MySQL installation directory.8. If the database server is not connected you will see (disconnected) next to the user name in the MySQL Server node in the Service window and you will not be able to expand the node. you can create a new database instance using the SQL Editor. Using the Create Table Dialog Using the SQL Editor In this exercise you will use the SQL editor to create the Counselor table. In the IDE's Services window. This allows you to take a closer look at the functionality offered by the Database Explorer. nickName VARCHAR (50). 3. and modify data maintained in tables. 4. 4. email VARCHAR (50). populate them with data. Click OK. 8. 6. expand the MyNewDatabase connection node ( ) and note that there are three subfolders: Tables. or by inputting an SQL query and running it directly from the SQL Editor. In the SQL Editor. Leave the checkbox unselected at this time. In the Database Explorer. telephone VARCHAR (25). lastName VARCHAR (50). CREATE TABLE Counselor ( 5. ) in the Services Creating Database Tables Now that you have connected to MyNewDatabase. Views and Procedures. type in the following query. The new database appears under the MySQL Server node in the Services window. firstName VARCHAR (50). The drop down list lets you assign these permissions to a specified user. 7. 9. 2. In the following exercises you will use the SQL editor to create the Counselor table and the Create Table dialog box to create the Subject table. This is a table definition for the Counselor table you are about to create. 1. only the admin user has the permissions to perform certain commands. right-click the MySQL Server node and choose Create Database. 10. Right-click the Tables folder and choose Execute Command. you can begin exploring how to create tables. Database connections that are open are represented by a complete connection node ( window. We will use MyNewDatabase for this tutorial. 1. In the IDE it is possible to add a database table by either using the Create Table dialog. type the name of the new database. A blank canvas opens in the SQL Editor in the main window. as well as NetBeans IDE's support for SQL files. In the Create MySQL Database dialog box. . MyNewDatabase is currently empty. id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT. Note: You can also grant full access to a given user. Right-click the new database node and choose Connect in the popup menu to open the connection to the database.1. By default. After you create the tables you will run an SQL script to populate the tables. 3. 2. Using the SQL Editor 2. The Create MySQL Database dialog box opens. To execute the query. right-click the Tables node in the Database Explorer and choose Refresh. 3. In the Table name text field. 2. 13. Select the Primary Key check box in the Add Column dialog box. Click OK. Note that when you select the Key check box. or right-click within the SQL Editor and choose Run Statement. Choose SMALLINT for data type from the Type drop-down list. 12. The Refresh option updates the Database Explorer's UI component to the current status of the specified database. primary keys cannot contain a Null value. Because all rows need to be identified. right-click the Tables node and choose Create Table. . The Create Table dialog opens. 1. either click the Run SQL ( ) button in the task bar at the top (Ctrl-Shift-E). SQL adheres to strict syntax rules which you should be familiar with when working in the IDE's Editor. Using the Create Table Dialog In this exercise you will use the Create Table dialog box to create the Subject table. This is because primary keys are used to identify a unique row in the database. type Subject. For the Name of the column. To verify changes. feedback from the SQL engine is generated in the Output window indicating whether execution was successful or not. memberSince DATE DEFAULT '0000-00-00'. Note: Queries formed in the SQL Editor are parsed in Structured Query Language (SQL). and by default form the table index. starting with the primary key ( ). enter id.11. Upon running a query. PRIMARY KEY (id) ). and you receive a message similar to the following in the Output window. All tables found in relational databases must contain a primary key. The IDE generates the Counselor table in the database. the Index and Unique check boxes are also automatically selected and the Null check box is deselected. You are specifying the primary key for your table. Click Add Column. 14. In the Database Explorer. 5. 4. If you expand the table node you can see the columns (fields) you created. Note that the new Counselor table node ( ) now displays under Tables in the Database explorer. then click OK. To execute the query. A blank canvas opens in the SQL Editor in the main window. When you choose View Data. To add a new record (row) to the Counselor table. '"The Dragon"'. in the Database Explorer. the Counselor table displays. In this example.6. a query to select all the data from the table is automatically generated in the upper region of the SQL Editor. . you can see a message indicating that the query was successfully executed. Repeat this procedure by adding the remaining columns. 5. To verify that the new record has been added to the Counselor table. You are creating a table named Subject that will hold data for each of the following records. The IDE generates the Subject table in the database. Note that a new row has been added with the data you just supplied from the SQL query. The results of the statement are displayed in a table view in the lower region. o Name: name of the subject o Description: description of the subject o Counselor ID: counselor ID that corresponds to an ID from the Counselor table Make sure that the fields in your Create Table dialog match those shown above. you can make use of the SQL Editor in NetBeans IDE. In the Output window. do the following: 1. and you can see a new Subject table node ( ) immediately display under Tables in the Database Explorer.'334 612-5678'. Key Index Null [checked] [checked] Unique Column Name Data Type Size [checked] id SMALLINT 0 [checked] name VARCHAR 50 [checked] description VARCHAR 500 [checked] FK_counselorID SMALLINT 0 7.com'. In the SQL Editor. 2. A new SQL Editor pane opens in the main window. you can add. INSERT INTO Counselor VALUES (1. 'Ricky'. 3. right-click the Counselor table node and choose View Data. 'Steamboat'. modify and delete data maintained in database structures. type in the following query. By running SQL queries on a database. Choose Execute Command from the Tables folder in the Database Explorer. right-click within the SQL Editor and choose Run Statement. 'r_steamboat@ifpwafcad. '1996-01-01') 4. Working with Table Data In order to work with table data. as shown in the following table. In this manner. 2.Running an SQL Script Another way to manage table data in NetBeans IDE is by running an external SQL script directly in the IDE. such as JavaServer Pages (JSP). 3. Choose File > Open File from the IDE's main menu. JavaServer Pages Standard Tag Library (JSTL). For demonstrative purposes. To delete tables: 1. 2. If you have created an SQL script elsewhere. To run the SQL script on MyNewDatabase: 1. or Structured Query Language. Because the script overwrites these tables if they already exist. the table nodes are automatically removed from the Database Explorer. client-server architecture. Right-click the Counselor and Subject table nodes in the Database Explorer and choose Delete. the Java Database Connectivity (JDBC) API. The Refresh option updates the Database Explorer's UI component to the current status of the specified database. Make sure your connection to MyNewDatabase is selected from the Connection drop-down box in the toolbar at the top of the Editor. When you click Yes in the Confirm Object Deletion dialog box.sql and save it to a location on your computer. MySQL is a popular open source database management system commonly used in web applications due to its speed. delete the Counselor and Subject tables now so it becomes obvious that new tables are being created when the script is run. download ifpwafcad. for accessing and processing data contained in databases. . The script automatically opens in the SQL Editor. you can compare the tabular data with the data contained in the SQL script to see that they match Creating a Simple Web Application Using a MySQL Database This document describes how to create a simple web application that connects to a MySQL database server. The script is executed against the selected database. flexibility and reliability. Click the Run SQL ( ) button in the SQL Editor's task bar. and any feedback is generated in the Output window. which you have registered a connection for in the NetBeans IDE. Click Yes in the Confirm Object Deletion dialog box. In the file browser navigate to the location where you previously saved ifpwafcad. and two-tier. 4. This tutorial is a continuation from the Connecting to a MySQL Database tutorial and assumes that you have already created a MySQL database named MyNewDatabase. This tutorial is designed for beginners who have a basic understanding of web development and are looking to apply their knowledge using a MySQL database. To verify changes. This script creates two tables similar to what you just created above (Counselor and Subject). It also covers some basic ideas and technologies in web development. you can simply open it in NetBeans IDE and run it in the SQL Editor. 5. MySQL employs SQL. Note that the dialog box lists the tables that will be deleted. Choose View Data from the right-click menu of a selected table node to see the data contained in the new tables. and immediately populates them with data.sql and click Open. Note that the two new tables from the SQL script now display as a table nodes under MyNewDatabase in the Database Explorer. right-click the MyNewDatabase connection node in the Runtime window and choose Refresh. When a browser requests index. are contained in the MySQL database. Subject and Counselor.jsp) presents the user with a simple HTML form. Again. To follow this tutorial. and any content in SQL. which you create by completing the Connecting to a MySQL Database tutorial. then open it in the NetBeans IDE and run it on the MySQL database named MyNewDatabase. The application you build in this tutorial involves the creation of two JSP pages. in which a client communicates directly with a server. When the user submits his or her selection in the welcome page's HTML form. The MySQL Connector/J JDBC Driver. and apply JSTL technology to perform the logic that directly queries the database and inserts the retrieved data into the two pages.x or 4. If you need to compare your project with a working solution.The table data used in that tutorial is contained in ifpwafcad. the JSTL code within the page initiates a query on MyNewDatabase.x GlassFish Server Open Source Edition 3. 7. Essentially.jsp). you need the following software and resources. you can download the sample application.jsp. Software or Resource Version Required NetBeans IDE 7. The two database tables. a Java web application communicates directly with a MySQL database using the Java Database Connectivity API.2. This SQL file creates two tables. In this tutorial. 7. then populates them with sample data. the language understood by the database server (MySQL). Consider the following two-tier scenario. the JSTL code within the page initiates a . If needed. is included in the NetBeans IDE.0. 8.x MySQL Connector/J JDBC Driver version 5.4. the submit initiates a request for the response page (response. necessary for communication between Java platforms and the MySQL database protocol. Planning the Structure Simple web applications can be designed using a two-tier architecture. In each of these pages you use HTML and CSS to implement a simple interface. Subject and Counselor. MyNewDatabase.x Notes:    The Java download bundle of the NetBeans IDE enables you to install the GlassFish server. and inserts it into to the page before it is sent to the browser. You require the GlassFish server to work through this tutorial. it is the MySQL Connector/J JDBC Driver that enables communication between the Java code understood by the application server (the GlassFish server). save this file to your computer. The welcome page (index. Java EE bundle Java Development Kit (JDK) version 7 or 8 MySQL database server 5. It retrieves data from the Subject database table.3.sql and is also required for this tutorial. you develop a simple application for a fictitious organization named IFPWAFCAD. allowing the user to view data based upon his or her selection when the page is returned to the browser. Choose File > New Project (Ctrl-Shift-N. it retrieves data from both the Subject and Counselor tables and inserts it into to the page.query on MyNewDatabase. . This time. In Project Name. deploy. the IDE places projects in a NetBeansProjects folder located in your home directory. and run the application.jsp Creating a New Project Begin by creating a new Java web project in the IDE: 1. then select Web Application. In order to implement the scenario described above. Also. specify the location for the project on your computer. ⌘-Shift-N on Mac) from the main menu.) Click Next. 2. The New Project wizard allows you to create an empty web application in a standard IDE project. The standard project uses an IDE-generated Ant build script to compile. The International Former Professional Wrestlers' Association for Counseling and Development. enter IFPWAFCAD.jsp response. (By default. Select the Java Web category. index. Click Next. jsp is open in the editor.jsp) pages. the International Former Professional Wrestlers' Association for Counseling and Development!. Java EE 6 and Java EE 7 web projects do not require the use of the web. specify the GlassFish server as server which will be used to run the application. and it does not rely on any features specific to Java EE 6 or Java EE 7. and the NetBeans project template does not include the web. The welcome page implements an HTML form that is used to capture user data. working with servers other than the GlassFish server is beyond the scope of this tutorial. In the Java EE Version field. then Standard Deployment Descriptor.jsp file serves as the welcome page for the application. In the editor.jsp under the Web Pages node in the IFPWAFCAD project in the Projects window. double-click index. this tutorial demonstrates how to declare a data source in the deployment descriptor. Change the text between the <h1> tags to: Welcome to IFPWAFCAD. However. In the Server and Settings panel. click the Add button located next to the Server drop-down field.jsp) in the editor. Because the GlassFish server is included in the download. Note. it is automatically registered with the IDE. The index. The GlassFish server displays in the Server drop-down field if you installed the Java version of the NetBeans IDE. Note. In this section. and opens an empty JSP page (index. ⌘-Shift-8 on Mac) from the main menu. Hover your pointer over the Table icon from the HTML category and note that the default code snippet for the item displays. Preparing the Web Interface Begin by preparing the welcome (index. 3. 4. so you can set the project version to Java EE 5. If you want to use a different server for this project. The IDE creates a project template for the entire application.jsp) and response (response. Both pages implement an HTML table to display data in a structured fashion. (From the New File wizard. 2.xml deployment descriptor.3. However.    Setting up the welcome page Creating the response page Creating a stylesheet Setting up the welcome page Confirm that index.xml deployment descriptor. You could equally set the project version to Java EE 6 or Java EE 7 and then create a web. you also create a stylesheet that enhances the appearance of both pages. change the text between the <title> tags to: IFPWAFCAD Homepage. Open the IDE's Palette by choosing Window > Palette (Ctrl-Shift-8.xml file in Java EE 6 and Java EE 7 projects. and register a different server with the IDE. . select Java EE 5. Click Finish. If the file is not already open.) 5. select the Web category. 1. then click OK.jsp in the Action text field. 4. Add the following content to the table heading and the cell of the first table row (new content shown in bold): <table border="0"> <thead> <tr> <th>IFPWAFCAD offers expert counseling in a wide range of fields.</th> </tr> </thead> <tbody> <tr> <td>To view the contact details of an IFPWAFCAD certified former professional wrestler in your area. then double-click the HTML form ( ) icon in the Palette. Type in the following content between the <form> tags (new content shown in bold): .right-click in the Palette and choose Show Big Icons and Hide Item Names to have it display as in the image above. select a subject below:</td> </tr> 7. Place your cursor at a point just after the <h1> tags. To do so.You can configure the Palette to your liking . specify the following values then click OK: o o o Rows: 2 Columns: 1 Border Size: 0 The HTML table code is generated and added to your page. For the bottom row of the table. insert an HTML form. in the Palette. double-click the Table icon. (This is where you want to implement the new HTML table. place your cursor between the second pair of <td> tags. In the Insert Table dialog that displays. 8.) Then. 6. In the Insert Form dialog. type in response. 5. the International Former Professional Wrestlers' Association for Counseling and Development! </h2> <table border="0"> <thead> <tr> <th>IFPWAFCAD offers expert counseling in a wide range of fields.jsp"> <strong>Select a subject:</strong> <select name="subject_id"> <option></option> </select> <input type="submit" value="submit" name="submit" /> </form> </td> </tr> </tbody> </table> </body> To view this page in a browser. Press Enter to add an empty line after the content you just added and then double-click Drop-down List in the Palette to open the Insert Drop-down dialog box. right-click in the editor and choose Run File (Shift-F6. Your code is automatically formatted.jsp"> <strong>Select a subject:</strong> </form> </td> </tr> 9. 12. 11. Ctrl-Shift-F on Mac). then click OK.<tr> <td> <form action="response. Add a submit button item ( ) to a point just after the drop-down list you just added. select a subject below:</td> </tr> <tr> <td> <form action="response. To format your code. Fn-Shift-F6 on Mac). In the Insert Button dialog.</th> </tr> </thead> <tbody> <tr> <td>To view the contact details of an IFPWAFCAD certified former professional wrestler in your area. enter submit for both the Label and Name text fields. right-click in the editor and choose Format (Alt-Shift-F. Note that the code snippet for the drop-down list is added to the form. Type subject_id for the Name text field in the Insert Drop-down dialog and click OK. the JSP page is automatically compiled and deployed to your server. Later in the tutorial you will add JSTL tags that dynamically generate options based on the data gathered from the Subject database table. or invoke the editor's code completion as illustrated in the previous step. and should now look similar to the following: <body> <h2>Welcome to <strong>IFPWAFCAD</strong>. The IDE opens your default browser to display the page from its deployed location. 10. . The number of options for the drop-down is currently not important. You can either use the Palette to do this. When you do this. A template for the new response.jsp welcome page resides.{placeholder}. enter response. 1. 2. Accept any other default settings and click Finish.">{placeholder}</span></td> </tr> <tr> <td><strong>Counselor: </strong></td> <td>{placeholder} <br> <span style="font-size:smaller. then copy and paste the following HTML table into the body of the page: <table border="0"> <thead> <tr> <th colspan="2">{placeholder}</th> </tr> </thead> <tbody> <tr> <td><strong>Description: </strong></td> <td><span style="font-size:smaller. A new JSP node also displays under Web Pages in the Projects window. 5.jsp you must first create the file in your project. in the following steps you add placeholders which you will later substitute for the JSP code. This is the same location as where the index. Note that most of the content that displays in this page is generated dynamically using JSP technology.jsp page is generated and opens in the editor. Right-click the IFPWAFCAD project node in the Projects window and choose New > JSP. The New JSP File dialog opens.Creating the response page In order to prepare the interface for response. meaning that the file will be created in the project's web directory. font-style:italic. Note that Web Pages is currently selected for the Location field. Therefore. In the editor."> member since: {placeholder}</span> </td> </tr> . In the JSP File Name field. 3. Remove the <h1>Hello World!</h1> line between the <body> tags. font-style:italic. 4. change the title to: IFPWAFCAD . padding: 10px.jsp. . color: #555. right-click in the editor and choose Run File (Shift-F6. 2. then select Cascading Style Sheet and click Next.css file: body { font-family: Verdana. 3. sans-serif. width: 450px. add the following content to the style. } table { width: 580px. This tutorial assumes that you understand how style rules function.4em. background-color: #c5e7e0.jsp and response. Note that a node for style. In the editor. font-size: smaller. and how they affect corresponding HTML elements found in index. The page compiles.<tr> <td><strong>Contact Details: </strong></td> <td><strong>email: </strong> <a href="mailto:{placeholder}">{placeholder}</a> <br><strong>phone: </strong>{placeholder} </td> </tr> </tbody> </table> To view this page in a browser. Type style for CSS File Name and click Finish. color: #be7429. and opens in your default browser.css now displays within the project in the Projects window. Creating a stylesheet Create a simple stylesheet that enhances the display of the web interface. Fn-Shift-F6 on Mac). 1. The IDE creates an empty CSS file and places it in the same project location as index. and the file opens in the editor. Select the Web category. Arial. } th { text-align: left. font-size: 1. } h1 { text-align: left. font-weight: normal. padding: 50px. Open the New File wizard by pressing the New File ( ) button in the IDE's main toolbar. letter-spacing: 6px.jsp and response.jsp. is deployed to the GlassFish server. To remedy this. but returned to the pool. Any incoming requests that require access to the application's data layer use an already-created connection from the pool. Likewise. Also. After preparing the data source and connection pool for the server.sql. your database needs to be password-protected to create a data source and work with the GlassFish server in this tutorial.border-bottom: 1px solid. font-weight: normal. see Connecting to a MySQL Database before proceeding further. In both pages. mysql> FLUSH PRIVILEGES.css"> To quickly navigate between files that are open in the editor. For more information. This is typically done by creating an entry in the application's web. . you need you ensure that you have a MySQL database instance named MyNewDatabase set up that contains sample data provided in ifpwafcad. numerous connections are created and maintained in a connection pool. } a:link:hover { color: #be7429. the connection is not closed down. then select the file you are wanting. especially for applications that continuously receive a large number of requests. If you have not already done this. } 4. Important: From this point forward. Finally. font-weight: normal. This tutorial uses nbuser as an example password. you need to ensure that the database driver (MySQL Connector/J JDBC Driver) is accessible to the server. Link the stylesheet to index. } td { padding: 10px. text-decoration: none. then populates them with sample data. when a request is completed.jsp and response.user SET Password = PASSWORD('nbuser') -> WHERE User = 'root'.xml deployment descriptor. or if you need help with this task. Subject and Counselor. This SQL file creates two tables. you then need to instruct the application to use the data source.jsp. press Ctrl-Tab. add the following line between the <head> tags: <link rel="stylesheet" type="text/css" href="style. Creating a new connection for each client request can be very time-consuming. see the official MySQL Reference Manual: Securing the Initial MySQL Accounts. you can set the password from a command-line prompt. } a:link { color: #be7429. text-decoration: underline. navigate to your MySQL installation's bin directory in the command-line prompt and enter the following: shell> mysql -u root mysql> UPDATE mysql. Preparing Communication between the Application and Database The most efficient way to implement communication between the server and database is to set up a database connection pool. If you are using the default MySQL root account with an empty password. To set your password to nbuser. The following steps demonstrate how to declare a connection pool. When the application is deployed. then in the JNDI Name text field. or. Select the GlassFish server category. General Attributes. Click Next. The NetBeans JDBC Resource wizard allows you to perform both actions. see The JNDI Tutorial. Adding the database driver's JAR file to the server Setting up a JDBC data source and connection pool The GlassFish Server Open Source Edition contains Database Connection Pooling (DBCP) libraries that provide connection pooling functionality in a way that is transparent to you as a developer. 1.xml file. The JNDI API provides a uniform way for applications to find and access data sources. then select JDBC Resource and click Next. The JDBC data source relies on JNDI. In step 2. 3. Optionally. then click Next again to skip step 3. For more information on JDBC technology. and a data source that relies on the connection pool.1. and choose jdbc:mysql://localhost:3306/MyNewDatabase from the drop-down list. 4. Referencing the data source from the application 3. type in: Accesses the database that provides data for the IFPWAFCAD application. For more information. In Step 4. and creates the necessary resources. the Java Naming and Directory Interface. you can declare the resources that your application needs in a glassfish-resources. Click Next. as described below. type in jdbc/IFPWAFCAD. type in IfpwafcadPool for JDBC Connection Pool Name. see The Java Tutorials: JDBC Basics. . Setting up a JDBC data source and connection pool 2. For example. Additional Properties. add a description for the data source. you need to configure a JDBC (Java Database Connectivity) data source for the server which your application can use for connection pooling. the server reads in the resource declarations. You could configure the data source directly within the GlassFish server Admin Console. choose the Create New JDBC Connection Pool option. Make sure the Extract from Existing Connection option is selected. 2. To take advantage of this. 5. Open the New File wizard by pressing the New File ( ) button in the IDE's main toolbar. 7. within the <resources> tags.xml file that was created under the Server Resources node and note that. 6. you can open the glassfish-resources. In the Projects window. right-click the IFPWAFCAD project node and choose Deploy.Note: The wizard detects any database connections that have been set up in the IDE.xml file that contains entries for the data source and connection pool you specified. Click Finish. Therefore. Note that the new data source and connection pool are now . The server starts up if not already running. select javax. ⌘-5 on Mac) and looking for connection nodes ( ) under the Databases category. In Step 5. then locate the resources in the IDE's Services window: 1. and sets name-value properties for the new connection pool.ConnectionPoolDataSource in the Resource Type drop-down list. In the Projects window. You can verify what connections have been created by opening the Services window (Ctrl-5. a data source and connection pool have been declared containing the values you previously specified.sql. Open the Services window (Ctrl-5. you can deploy the project to the server. The wizard generates a glassfish-resources. To confirm that a new data source and connection pool are indeed registered with the GlassFish server. Note that the IDE extracts information from the database connection you specified in the previous step. you need to have already created a connection to the MyNewDatabase database at this point. ⌘-5 on Mac) and expand the Servers > GlassFish > Resources > JDBC > JDBC Resources and Connection Pools nodes. and the project is compiled and deployed to it. 2. 1. filters and listeners. expand the Configuration Files folder and double-click web. 2.xml deployment descriptor.sql. Database for IFPWAFCAD application. Expand the Resource References heading and click Add to open the Add Resource Reference dialog. If you specified Java EE 6 or Java EE 7 as the Java version when you created the project. but you can enter a human-readable description of the resource. click the Source tab located along the top of the editor. Type javax. Deployment descriptors are XML-based text files that contain information describing how an application is to be deployed to a specific environment. Click OK. as well as mappings for servlets. In the Projects window. you can create an entry in the application's web. The new resource is now listed under the Resource References heading. To do so.xml to open the file in the editor. e. Note.displayed: Referencing the data source from the application You need to reference the JDBC resource you just configured from the web application. 4.. For example. enter the resource name that you gave when configuring the data source for the server above (jdbc/IFPWAFCAD). <resource-ref> <description>Database for IFPWAFCAD application</description> <res-ref-name>jdbc/IFPWAFCAD</res-ref-name> .xml file. 3. The Description field is optional. Click the References tab located along the top of the editor. they are normally used to specify application context parameters and behavioral patterns.ConnectionPoolDataSource in the Resource Type field. Perform the following steps to reference the data source in the application's deployment descriptor. 6. For Resource Name.g. security settings. To verify that the resource is now added to the web. Notice that the following <resource-ref> tags are now included. you need to create the deployment descriptor file by choosing Web > Standard Deployment Descriptor in the New File wizard. 5. Click Close to exit the Servers manager.1. In the IDE's Projects window. ⌘-4 on Mac). if the driver is required and it is missing.jar file. the driver JAR file should be located within domain1. it does so automatically. Now. 3. The output indicates that the MySQL driver is deployed to a location in the GlassFish server.sql. 6. if you return to the domain1/lib subfolder on your computer. and the Domain Name field indicates the name of the domain your server is using.6-bin.and if not.jar file has been automatically added. you can see that the mysql-connector-java5. As shown in the image above.1. In the case of MySQL. If you do not see the driver JAR file. On your computer. . it initiates a check to determine whether any drivers are required for the server's deployed applications. you would need to locate your database driver's installation directory and copy the mysql-connectorjava-5. 5. choose Deploy from the right-click menu of the project node. 2.1. Deploy your project to the server. Each instance runs applications in a unique domain.ConnectionPoolDataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> Adding the database driver's JAR file to the server Adding the database driver's JAR file is another step that is vital to enabling the server to communicate with your database. In the main pane. the IDE's bundled driver is deployed to the appropriate location on the server. Fortunately. select the Enable JDBC Driver Deployment option. make a note of the path indicated in the Domains folder text field. 4. Because you should have already deployed the IFPWAFCAD project to the server. Choose Tools > Servers to open the Servers manager. You can view progress in the IDE's Output window (Ctrl-4. navigate to the GlassFish server installation directory and drill into the domains > domain1 > lib subfolder. Before you close the Servers manager.6-bin. you should see the mysql-connector-java-5. Ordinarily.6-bin. The IDE provides a JDBC driver deployment option. the IDE's server management is able to detect at deployment whether the JAR file has been added . which is the default domain created upon installing the GlassFish server. When you connect to the GlassFish server in the IDE. 1. In order to demonstrate this. perform the following step. you are actually connecting to an instance of the application server. If the option is enabled.<res-type>javax. open the Servers manager (Choose Tools > Servers). Select the GlassFish server in the left pane.jar file from the driver's root directory into the library folder of the server you are using. 1. Both pages require that you implement an SQL query that utilizes the data source created earlier in the tutorial. (Older versions of the GlassFish server use the jstl-impl. you do not have to perform any steps for this task.jsp placeholders that you created earlier in the tutorial. you can now implement the JSTL code that enables pages to generate content dynamically. To do so. JSTL provides the following four basic areas of functionality.jar library. structural tasks such as iterators and conditionals for handling flow control fmt: internationalization and localization message formatting sql: simple database access xml: handling of XML content This tutorial focuses on usage of the core and sql tag libraries. .jsp.. and searching for the javax. 1.jsp. Hover your mouse over the DB Report item in the Palette. you need to access all names from the Subject database table. Implement JSTL code Adding the JSTL library to the project's classpath You can apply the JavaServer Pages Standard Tag Library (JSTL) to access and display data taken from the database. The IDE provides several database-specific JSTL snippets which you can select from the Palette (Ctrl-Shift-8. perform the following three tasks. Implementing JSTL code Now you can implement the code that dynamically retrieves and displays data for each page. The GlassFish server includes the JSTL library by default.Adding Dynamic Logic Returning to the index. based on user input.servlet. You can verify this by expanding the GlassFish Server node under the Libraries node in the Projects window. index. i.jsp and response.jar library.jsp In order to dynamically display the contents of the form in index. Add the JSTL library to the project's classpath 2. ⌘-Shift-8 on Mac).jstl.e.     core: common.) Because the GlassFish server libraries are by default added to your project's classpath. name FROM Subject </sql:query> <table border="1"> <!-. The following content is generated in the index.com/jsp/jstl/sql"%> <%-Document : index Author : nbuser --%> <sql:query var="subjects" dataSource="jdbc/IFPWAFCAD"> SELECT subject_id.sun.The DB Report item uses the <sql:query> tag to create an SQL query. Place your cursor above the <%@page . Click OK. %> declaration (line 7).column data --> <c:forEach var="row" items="${subjects. enter the following details: o Variable Name: subjects o Scope: page o Data Source: jdbc/IFPWAFCAD o Query Statement: SELECT subject_id. then it uses the <c:forEach> tag to loop through the query's resultset and output the retrieved data. 2. then double-click the DB Report item in the Palette.columnNames}"> <th><c:out value="${columnName}"/></th> </c:forEach> </tr> <!-..01 Transitional//EN" "http://www.jsp file..) <%@taglib prefix="c" uri="http://java.com/jsp/jstl/core"%> <%@taglib prefix="sql" uri="http://java.w3.dtd"> .column headers --> <tr> <c:forEach var="columnName" items="${subjects.rowsByIndex}"> <tr> <c:forEach var="column" items="${row}"> <td><c:out value="${column}"/></td> </c:forEach> </tr> </c:forEach> </table> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.sun.org/TR/html4/loose. (New content shown in bold. name FROM Subject 3. In the dialog that displays. <form action="response. <form action="response..Note that the IDE automatically added taglib directives needed for the JSTL tags used in the generated content (<sql:query> and <c:forEach>). as recorded in the database. the GlassFish server) to perform a loop on all table rows. (Changes are displayed in bold). The value of each item becomes the subject_id. and for each row.subject_id}">${row. the IDE deploys the project to the GlassFish server. one is nested inside the other.jsp"> <strong>Select a subject:</strong> <select name="subject_id"> <c:forEach var="row" items="${subjects.. This can be particularly useful when prototyping. Run the project to see how it displays in a browser. Examine the column data in the generated code. As you can see.name}</option> </c:forEach> </select> . The following steps demonstrate how to integrate the generated code into the HTML drop-down list you created earlier in the tutorial. the index page is compiled into a servlet. simpler way to integrate the <c:forEach> tags into the HTML form would be as follows. names the tag library that defines them. data for the entire table is displayed. 5.e.rowsByIndex}"> <c:forEach var="column" items="${row}"> <option value="<c:out value="${column}"/>"><c:out value="${column}"/></option> </c:forEach> </c:forEach> </select> <input type="submit" value="submit" name="submit" /> </form> An alternative. Integrate the <c:forEach> tags into the HTML form as follows. When you choose Run.jsp"> <strong>Select a subject:</strong> <select name="subject_id"> <c:forEach var="row" items="${subjects. 4. 6. JSTL) tags.rows}"> <option value="${row. The code generated from the DB Report item creates the following table in the welcome page. In this manner. and enables you to view table data from the database in your browser. A taglib directive declares that the JSP page uses custom (i. and the welcome page opens in your default browser. and specifies their tag prefix. the DB Report item enables you to quickly test your database connection. it loops through all columns. and the output text becomes the name. Right-click the project node in the Projects window and choose Run. This causes the JSP container (i.e. Two <c:forEach> tags are used. 7.. the <c:forEach> tags loop through all subject_id and name values from the SQL query. 2. 1.com/jsp/jstl/core"%> <%@taglib prefix="sql" uri="http://java. This means that when you modify and save a file.sun. %> declaration (line 7). and insert each pair into the HTML <option> tags. response. The query you create must select the counselor record whose counselor_id matches the counselor_idfk from the selected subject record.. ⌘-S on Mac). .dtd"> 8. You do not need to redeploy your project because compile-on-save is enabled for your project by default. and double-click DB Query in the Palette to open the Insert DB Query dialog box. 9. You can enable and disable compile-on-save for your project in the Compiling category of the Properties window of the project.) <%@taglib prefix="c" uri="http://java. Delete the table that was generated from the DB Report item. In this manner. the form's drop-down list is populated with data.<input type="submit" value="submit" name="submit" /> </form> In either case.columnNames}"> <th><c:out value="${columnName}"/></th> </c:forEach> </tr> <!-. name FROM Subject </sql:query> <table border="1"> <!-.sun.rowsByIndex}"> <tr> <c:forEach var="column" items="${row}"> <td><c:out value="${column}"/></td> </c:forEach> </tr> </c:forEach> </table> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.com/jsp/jstl/sql"%> <%-Document : index Created on : Dec 22. 7:39:49 PM Author : nbuser --%> <sql:query var="subjects" dataSource="jdbc/IFPWAFCAD"> SELECT subject_id.org/TR/html4/loose.jsp The response page provides details for the counselor who corresponds to the subject chosen in the welcome page. Enter the following details in the Insert DB Query dialog box.column data --> <c:forEach var="row" items="${subjects. Refresh the welcome page of the project in your browser. Note that the drop-down list in the browser now contains subject names that were retrieved from the database. (Deletion shown below as strike-through text.w3. Save your changes (Ctrl-S.column headers --> <tr> <c:forEach var="columnName" items="${subjects. the file is automatically compiled and deployed and you do not need to recompile the entire project.01 Transitional//EN" "http://www. Place your cursor above the <%@page . 2009. com/jsp/jstl/sql"%> <%-Document : response Created on : Dec 22. Counselor WHERE Counselor. Also. Counselor WHERE Counselor.subject_id}"/> </sql:query> . Click OK. Because this query relies on the subject_id value that was submitted from index.01 Transitional//EN" "http://www.jsp file.subject_id}"/> </sql:query> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.e.o o o o Variable Name: counselorQuery Scope: page Data Source: jdbc/IFPWAFCAD Query Statement: SELECT * FROM Subject.) <%@taglib prefix="sql" uri="http://java.counselor_id = Subject.w3.counselor_id = Subject. Counselor WHERE Counselor. 4.subject_id = ? <sql:param value="${param. Use a <c:set> tag to set a variable that corresponds to the first record (i.counselor_id = Subject. (New content shown in bold. you can extract the value using an EL (Expression Language) statement in the form of ${param.) <sql:query var="counselorQuery" dataSource="jdbc/IFPWAFCAD"> SELECT * FROM Subject.subject_id}.counselor_idfk AND Subject. (New content shown in bold.jsp. note that you used an <sql:param> tag directly within the query. and then pass it to the <sql:param> tag so that it can be used in place of the SQL question mark (?) during runtime.counselor_idfk AND Subject.subject_id = ? <sql:param value="${param.subject_id = ? <sql:param value="${param. 2009.sun.subject_id}"/> 3. The following content is generated in the response..org/TR/html4/loose.dtd"> Note that the IDE automatically added the taglib directive needed for the <sql:query> tag.counselor_idfk AND Subject. 8:52:57 PM Author : nbuser --%> <sql:query var="counselorQuery" dataSource="jdbc/IFPWAFCAD"> SELECT * FROM Subject. row) of the resultset returned from the query. However.com/jsp/jstl/sql"%> 7.rows[0]}"/> Although the resultset returned from the query should only contain a single record. Note that because of NetBeans' Compile on Save feature.css"> <title>${counselorDetails.first_name} ${counselorDetails. this is a necessary step because the page needs to access values from the record using EL (Expression Language) statements.email}</a> <br><strong>phone: </strong>${counselorDetails.name}</th> </tr> <tr> <td><strong>Description: </strong></td> <td><span style="font-size:smaller. replace all placeholders with EL statements code that display the data held in the counselorDetails variable. you were able to access values from the resultset simply by using a <c:forEach> tag. 5. charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="style. so that the <c:set> tag is understood. .sun. the <c:forEach> tag operates by setting a variable for the rows contained in the query. font-style:italic.jsp page opens in the IDE's default browser.sun.name}</title> </head> <body> <table> <tr> <th colspan="2">${counselorDetails. you can be sure the deployment contains your latest changes. The index. Try running it again to see how it displays in a browser.telephone}</td> </tr> </table> </body> </html> Running the Completed Application You've now completed the application.member_since}</em></span></td> </tr> <tr> <td><strong>Contact Details: </strong></td> <td><strong>email: </strong> <a href="mailto:${counselorDetails. Click the Run Project ( ) button in the main toolbar. font-style:italic. In the HTML markup. (Changes below shown in bold): <html> <head> <meta http-equiv="Content-Type" content="text/html.description}</span></td> </tr> <tr> <td><strong>Counselor: </strong></td> <td><strong>${counselorDetails.">${counselorDetails.<c:set var="counselorDetails" value="${counselorQuery. you do not need to worry about compiling or redeploying the application."> <em>member since: ${counselorDetails.email}">${counselorDetails.) 6. (New content shown in bold.last_name}</strong> <br><span style="font-size:smaller. thus enabling you to extract values by including the row variable in EL statements.nick_name} ${counselorDetails. When you run a project.com/jsp/jstl/core"%> <%@taglib prefix="sql" uri="http://java. Recall that in index.jsp. <%@taglib prefix="c" uri="http://java. Add the taglib directive for the JSTL core library to the top of the file. showing details corresponding to your selection. the following examinations may be useful. If your application does not display correctly. It also demonstrated how to construct an application using a basic two-tier architecture.   To connect to the MySQL database server. JSTL. you can create a connection by right-clicking the MySQL driver node ( ) and choosing Connect Using. The fields provided in the New Database Connection dialog mirror the URL string entered in the Show JDBC URL . and JNDI as a means of accessing and displaying data dynamically. JDBC.When index. This document demonstrated how to create a simple web application that connects to a MySQL database.jsp displays in the browser. ⌘-5 on Mac) to ensure that the MySQL server is running.      Do database resources exist? Do the connection pool and data source exist on the server? Is the MySQL Connector/J driver accessible to the GlassFish server? Is the database password-protected? Are the connection pool properties correctly set? Do database resources exist? Use the IDE's Services window (Ctrl-5. You should now be forwarded to the response. right-click the MySQL Server node and choose Connect. Enter the required details in the dialog that displays.jsp page. If a connection node ( ) for MyNewDatabase does not display in the Services window. or if you are receiving a server error. and utilized numerous technologies including JSP. select a subject from the drop-down list and click submit. This concludes the Creating a Simple Web Application Using a MySQL Database tutorial. Troubleshooting Most of the problems that occur with the tutorial application are due to communication difficulties between the GlassFish Server Open Source Edition and the MySQL database server. and that MyNewDatabase is accessible and contains appropriate table data. 6-bin.)  Locate the GlassFish server installation folder on your computer and drill down into the GlassFish domains/domain1/lib subfolder.) Is the MySQL Connector/J driver accessible to the GlassFish server? Make sure that the MySQL Connector/J driver has been deployed to the GlassFish server. If you are using the default MySQL root account with an empty password. Expand the Connection Pools node to view the IfpwafcadPool connection pool that was created from glassfish-resources. (This is discussed in Adding the database driver's JAR file to the server.xml contained in the project should instruct the server to create a JDBC resource and connection pool. You can determine whether these exist from the Servers node in the Services window. navigate to your MySQL installation's bin directory in the command-line prompt and enter the following: shell> mysql -u root mysql> UPDATE mysql. mysql> FLUSH PRIVILEGES.1. Do the connection pool and data source exist on the server? After deploying the application to the GlassFish server. you can set the password from a command-line prompt. expand the MyNewDatabase connection node ( ) and locate the MyNewDatabase catalog node ( ). option. the glassfish-resources. . Here you should find the mysql-connector-java-5. if you know the URL (e. (This is demonstrated above. and the remaining dialog fields become automatically populated. Therefore. You can view table data by right-clicking a table node and choosing View Data. see the official MySQL Reference Manual: Securing the Initial MySQL Accounts.. Expand the catalog node to view existing tables. Is the database password-protected? The database needs to be password-protected to enable the GlassFish server data source to work properly in this tutorial.g.xml.  Expand the Servers > the GlassFish Server > Resources node. To ensure that the Subject and Counselor tables exist and that they contain sample data.xml.user SET Password = PASSWORD('nbuser') -> WHERE User = 'root'. Expand JDBC Resources to view the jdbc/IFPWAFCAD data source that was created from glassfish-resources. For more information. jdbc:mysql://localhost:3306/MyNewDatabase) you can paste it into the Show JDBC URL field.jar file.     To set your password to nbuser. 1 versions of MySQL Server on Windows. 3. mysql-installer-community-5. Note: The Setting Up the MySQL Database Server 5. Details for the IfpwafcadPool connection pool display in the main window. 3. refer to the Installing and Upgrading MySQL documentation. top Starting the Installation After the download completes. Go to http://dev.msi) and click Run. it describes a sequence of required steps. The MySQL Installer starts. 2. select Install MySQL Products. Right-click the GlassFish server node and choose View Admin Console. Contents    Starting the Download Starting the Installation See Also Starting the Download 1. In the tree on the left side of the console. 4.6. 6. This document recommends a sequence of steps to set up the MySQL database server 5. ⌘-5 on Mac) and expand the Servers node.14. If the ping fails.com/downloads/installer/. Open the Services window (Ctrl-5.1 versions in the Windows Operating System document provides the instructions on setting up the 5. It does not cover MySQL configuration details. On the Welcome panel. 2.Are the connection pool properties correctly set? Ensure that the connection pool is working correctly for the server. If the connection pool is set up correctly. click the Additional Properties tab and ensure that the listed property values are correctly set. expand the Resources > JDBC > JDBC Connection Pools > IfpwafcadPool node. Save the installer file to your system. Setting Up the MySQL Database Server in the Windows Operating System The MySQL database server is one of the most popular open-source database servers commonly used in web application development.6 versions in the Windows operating system. . Click the Ping button. Enter the username and password if you are prompted. You can view the username and password in the Servers manager. Right-click the downloaded installation file (for example. For information about installing and configuring MySQL database server for other operating systems. 2. 1. Click the Download button. run the installer as follows: 1.mysql. 5. you will see a 'Ping Succeeded' message.0. o Advanced Configuration. Click Finish. set the following options: o Windows Service Name. Remember the root password . Click OK. Click Next.  MySQL Root Password.leave it unchanged if there is not special reason to change it. click Next. o MySQL User Accounts. click Next. Note: Choosing this option is necessary to get to the panel for setting the network options where you will turn off the firewall for the port used by the MySQL server. 8. 9. When the server installation is completed successfully. Ensure the checkbox is selected and specify the options below:  Port Number.creating. At the second MySQL Server Configuration page (2/3). click Next. !phpuser). Click Next. 15. The default setting is 3306 . and click Next. Recommended for most scenarios. Enter the root user's password. 10.x is selected. Note: The root user is a user who has full access to the MySQL database server . set the following options: o Root Account Password. Select the Show Advanced Options checkbox to display an additional configuration page for setting advanced options for the server instance if required. Click Add User to create a user account. o Run Windows Service as. On the Installation panel. a database role. When the configuration is completed successfully. 6. enter a user name. click the acceptance checkbox. 7.3. On the Check Requirements panel. Specify the connection port. Note: To check that the installation has completed successfully. choose the Custom option and click Next. ensure MySQL Server 5. Choose either:  Standard System Account. click Execute. and removing users. run the Task Manager. 11. Specify a Windows Service Name to be used for the MySQL server instance.exe is on the Processes list . 12. When the operation is complete. On the Configuration panel. o Enable TCP/IP Networking. click Next. and so on. 5. the information message appears on the Installation panel. 4. 13.  Repeat Password. On the Feature Selection panel. and click Next. Select to add firewall exception for the specified port.6. click Execute. On the License Information panel.you will need it later when creating a sample database. . the information message appears on the Complete panel. On the Setup Type panel. Leave the checkbox selected if the MySQL server is required to automatically start at system startup time. updating. On the Find latest products panel. At the third MySQL Server Configuration page (3/3). 14. In the MySQL User Details dialog box. Click Next. An existing user account recommended for advanced scenarios. review the license agreement. and a password (for example. At the Configuration Overview page. set the following options: o Server Configuration Type. o Start the MySQL Server at System Startup.  Open Firewall port for network access. Click Next.  Custom User. Retype the root user's password. Select the Development Machine option.the database server is running. At the first MySQL Server Configuration page (1/3). If the MySQLd-nt. Documents Similar To Connecting to Oracle Database From NetBeans IDESkip carouselcarousel previouscarousel nextMS Access NotesAutoIncrement_oracleTableSQL-NOTESschema.docxCodingMicrosoft Sq l Server Notes for ProfessionalsSQL Update ExampleProject on Library ManagementSolSQL InroductionSQL StatementLecture4 More SQLsqlnotestt6thPractical List Solution (DBMS) LabMaintaining Data Integrity in MYSQLp1 Tables and RelationsOracle11g SlidesStructured Query LanguageTuningrelational modelingService_Contracts_Import Scope and LimitationsDB2DB2 Survival Guideservoytipssys aid Database GuideOracle Apps Data StructureSQL refernceSQL 10985B ENU CompanionIndex Monitoring and Foreign Key IndexesDifference Between CASE and DECODEMore From GiovanniBanegasSkip carouselcarousel previouscarousel nextApuntes Latex - Formulas Matematicas.pdfMisiónDerivadas e Integralescodigo.pdfPráctica 1Actividad Final - Valor 25Dibujar en LatexMisión.docxFLH39EAIEOP2TUY.pdfCalendarizacion+2017++IV+parcial+alumnosIdenti Dad EsMM202, Tarea I ParcialSialabo Mm111 y Mma_111 Unah Iip2017HOMEWORK+SCHEDULE+4th+grade+Feb+27+to+March+3macrosVisualBasicParaExcel.pdfNivelacion Lab. Inf. IIIBrazo Robotico de 4 GradosOperaciones Con MatricesIntroduction to Developing Web ApplicationsI Guia de Vectores y Matrices, I 2015Prueba 1 MM111StartProgramación de juegos para principiantesTutorial Base de Datos con Netbeans.pdfBest Books About Net BeansJava EE 7 Development with NetBeans 8by David R. HeffelfingerMastering NetBeansby David SalterPHP Application Development with NetBeans: Beginner's Guideby M. A. Hossain TonuNetBeans IDE 8 Cookbookby David Salter and Rhawi DantasiReport 3.7by Shamsuddin AhammadNetBeans Platform 6.9 Developer's Guideby Jurgen PetriFooter MenuBack To TopAboutAbout ScribdPressOur blogJoin our team!Contact UsJoin todayInvite FriendsGiftsLegalTermsPrivacyCopyrightSupportHelp / FAQAccessibilityPurchase helpAdChoicesPublishersSocial MediaCopyright © 2018 Scribd Inc. .Browse Books.Site Directory.Site Language: English中文EspañolالعربيةPortuguês日本語DeutschFrançaisTurkceРусский языкTiếng việtJęzyk polskiBahasa indonesiaSign up to vote on this titleUsefulNot usefulMaster your semester with Scribd & The New York TimesSpecial offer for students: Only $4.99/month.Master your semester with Scribd & The New York TimesRead Free for 30 DaysCancel anytime.Read Free for 30 DaysYou're Reading a Free PreviewDownloadClose DialogAre you sure?This action might not be possible to undo. Are you sure you want to continue?CANCELOK
Copyright © 2024 DOKUMEN.SITE Inc.