This is an automated email from the ASF dual-hosted git repository. vieiro pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-netbeans-website.git
The following commit(s) were added to refs/heads/master by this push: new b68a7cb ide/mysql minor changes b68a7cb is described below commit b68a7cb54a04348fb3dd7c6a188ba202b48706e1 Author: Antonio Vieiro <vie...@users.noreply.github.com> AuthorDate: Mon Jan 28 21:51:33 2019 +0100 ide/mysql minor changes NOTEs were not recognized, block images instead of inline images, minor fixes. --- .../src/content/kb/docs/ide/mysql.asciidoc | 70 +++++++++++++++------- 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/netbeans.apache.org/src/content/kb/docs/ide/mysql.asciidoc b/netbeans.apache.org/src/content/kb/docs/ide/mysql.asciidoc index bfa2a2b..bf8ba96 100644 --- a/netbeans.apache.org/src/content/kb/docs/ide/mysql.asciidoc +++ b/netbeans.apache.org/src/content/kb/docs/ide/mysql.asciidoc @@ -40,36 +40,46 @@ NOTE: This tutorial assumes that you already have the MySQL RDBMS installed and NetBeans IDE comes bundled with support for the MySQL RDBMS. Before you can access the MySQL Database Server in NetBeans IDE, you must configure the MySQL Server properties. 1. Right-click the Databases node in the Services window and choose Register MySQL Server to open the MySQL Server Properties dialog box. + image::images/mysql-props1.png[] + +[start=2] 2. Confirm that the server host name and port are correct. Notice that the IDE enters `localhost` as the default server host name and `3306` as the default server port number. +[start=3] 3. Enter the Administrator user name (if not displayed). -*Note: *You need administrative access to be able to create and remove databases. +NOTE: You need administrative access to be able to create and remove databases. 4. Enter the Administrator password. The default is set to blank. -*Note: * A blank password can also be a password. +NOTE: A blank password can also be a password. 5. Click the Admin Properties tab at the top of the dialog box. The Admin Properties tab is then displayed, allowing you to enter information for controlling the MySQL Server. + +[start=6] 6. In the Path/URL to admin tool field, type or browse to the location of your MySQL Administration application such as the MySQL Admin Tool, PhpMyAdmin, or other web-based administration tools. -*Note: *`mysqladmin` is the MySQL admin tool found in the `bin` folder of the MySQL installation directory. It is a command-line tool and not ideal for use with the IDE. +NOTE: `mysqladmin` is the MySQL admin tool found in the `bin` folder of the MySQL installation directory. It is a command-line tool and not ideal for use with the IDE. Type any arguments for the admin tool in the Arguments field. -7. -In the Path to start command, type or browse to the location of the MySQL start command. To find the start command, look for `mysqld` in the `bin` folder of the MySQL installation directory. -*Note: * The recommended binary for Unix and NetWare is `mysql_safe`. The start command may also vary if MySQL was installed as part of an AMP installation. +[start=7] +7. In the Path to start command, type or browse to the location of the MySQL start command. To find the start command, look for `mysqld` in the `bin` folder of the MySQL installation directory. + +NOTE: The recommended binary for Unix and NetWare is `mysql_safe`. The start command may also vary if MySQL was installed as part of an AMP installation. Type any arguments for the start command in the Arguments field. + +[start=8] 8. In the Path to stop command field, type or browse to the location of the MySQL stop command. This is usually the path to `mysqladmin` in the `bin` folder of the MySQL installation directory. If the command is `mysqladmin`, in the Arguments field, type `-u root stop` to grant `root` permissions for stopping the server. -9. -When finished, the Admin Properties tab should resemble the following figure. If you are satified with your configuration, click OK. + +[start=9] +9. When finished, the Admin Properties tab should resemble the following figure. If you are satified with your configuration, click OK. image::images/mysql-props2.png[] @@ -92,15 +102,20 @@ A common way of interacting with databases is through an SQL editor. NetBeans ID 1. In the IDE's Services window, right-click the MySQL Server node and choose Create Database. The Create MySQL Database dialog box opens. + +[start=2] 2. In the Create MySQL Database dialog box, type the name of the new database. We will use `MyNewDatabase` for this tutorial. Leave the checkbox unselected at this time. + image::images/create-db-dbx.png[] -*Note: *You can also grant full access to a given user. By default, only the admin user has the permissions to perform certain commands. The drop down list lets you assign these permissions to a specified user. +NOTE: You can also grant full access to a given user. By default, only the admin user has the permissions to perform certain commands. The drop down list lets you assign these permissions to a specified user. +[start=3] 3. Click OK. The new database appears under the MySQL Server node in the Services window. +[start=4] 4. Right-click the new database node and choose Connect in the popup menu to open the connection to the database. Database connections that are open are represented by a complete connection node (image::images/connection-node-icon.png[]) in the Services window. @@ -116,6 +131,7 @@ Now that you have connected to ``MyNewDatabase`` , you can begin exploring how 2. <<usingCreateTable,Using the Create Table Dialog>> +[[usingSQLEditor]] === Using the SQL Editor In this exercise you will use the SQL editor to create the `Counselor` table. @@ -124,7 +140,7 @@ In this exercise you will use the SQL editor to create the `Counselor` table. 2. Right-click the Tables folder and choose Execute Command. A blank canvas opens in the SQL Editor in the main window. 3. In the SQL Editor, type in the following query. This is a table definition for the ``Counselor`` table you are about to create. -[source,java] +[source,sql] ---- CREATE TABLE Counselor ( @@ -138,15 +154,20 @@ CREATE TABLE Counselor ( PRIMARY KEY (id) ); ---- -*Note: *Queries formed in the SQL Editor are parsed in Structured Query Language (SQL). SQL adheres to strict syntax rules which you should be familiar with when working in the IDE's Editor. Upon running a query, feedback from the SQL engine is generated in the Output window indicating whether execution was successful or not. + +NOTE: Queries formed in the SQL Editor are parsed in Structured Query Language (SQL). SQL adheres to strict syntax rules which you should be familiar with when working in the IDE's Editor. Upon running a query, feedback from the SQL engine is generated in the Output window indicating whether execution was successful or not. + +[start=4] 4. To execute the query, either click the Run SQL (image::images/run-sql-button.png[]) button in the task bar at the top (Ctrl-Shift-E), or right-click within the SQL Editor and choose Run Statement. The IDE generates the ``Counselor`` table in the database, and you receive a message similar to the following in the Output window. + image::images/create-counselor-query.png[] -5. -To verify changes, right-click the Tables node in the Database Explorer and choose Refresh. The Refresh option updates the Database Explorer's UI component to the current status of the specified database. Note that the new ``Counselor`` table node (image::images/table-node.png[]) now displays under Tables in the Database explorer. If you expand the table node you can see the columns (fields) you created, starting with the primary key (image::images/primary-key-icon.png[]). -image::images/counselor-table.png[] +[start=5] +5. To verify changes, right-click the Tables node in the Database Explorer and choose Refresh. The Refresh option updates the Database Explorer's UI component to the current status of the specified database. Note that the new ``Counselor`` table node (image:images/table-node.png[]) now displays under Tables in the Database explorer. If you expand the table node you can see the columns (fields) you created, starting with the primary key (image:images/primary-key-icon.png[]). +image::images/counselor-table.png[] +[[usingCreateTable]] === Using the Create Table Dialog In this exercise you will use the Create Table dialog box to create the `Subject` table. @@ -155,10 +176,12 @@ In this exercise you will use the Create Table dialog box to create the `Subject 2. In the Table name text field, type ``Subject`` . 3. Click Add Column. 4. For the Name of the column, enter ``id`` . Choose ``SMALLINT`` for data type from the Type drop-down list. Click OK. + image::images/add-column-dialog.png[] + +[start=5] 5. Select the Primary Key check box in the Add Column dialog box. You are specifying the primary key for your table. All tables found in relational databases must contain a primary key. Note that when you select the Key check box, the Index and Unique check boxes are also automatically selected and the Null check box is deselected. This is because primary keys are used to identify a unique row in the database, and by default form the table index. Because all rows need to be identified, p [...] -6. -Repeat this procedure by adding the remaining columns, as shown in the following table. +6. Repeat this procedure by adding the remaining columns, as shown in the following table. |=== |Key |Index |Null |Unique |Column Name |Data Type |Size @@ -177,9 +200,10 @@ You are creating a table named ``Subject`` that will hold data for each of the * *Name: *name of the subject * *Description: *description of the subject * *Counselor ID: *counselor ID that corresponds to an ID from the Counselor table + image::images/create-table-subject.png[] -Make sure that the fields in your Create Table dialog match those shown above, then click OK. The IDE generates the ``Subject`` table in the database, and you can see a new ``Subject`` table node (image::images/table-node.png[]) immediately display under Tables in the Database Explorer. +Make sure that the fields in your Create Table dialog match those shown above, then click OK. The IDE generates the ``Subject`` table in the database, and you can see a new ``Subject`` table node (image:images/table-node.png[]) immediately display under Tables in the Database Explorer. == Working with Table Data @@ -189,15 +213,15 @@ In order to work with table data, you can make use of the SQL Editor in NetBeans 1. Choose Execute Command from the Tables folder in the Database Explorer. A blank canvas opens in the SQL Editor in the main window. 2. In the SQL Editor, type in the following query. -[source,java] +[source,sql] ---- INSERT INTO Counselor VALUES (1, 'Ricky', '"The Dragon"', 'Steamboat','334 612-5678', 'r_steamb...@ifpwafcad.com', '1996-01-01') ---- + 3. To execute the query, right-click within the SQL Editor and choose Run Statement. In the Output window, you can see a message indicating that the query was successfully executed. -4. -To verify that the new record has been added to the ``Counselor`` table, in the Database Explorer, right-click the ``Counselor`` table node and choose View Data. A new SQL Editor pane opens in the main window. When you choose View Data, a query to select all the data from the table is automatically generated in the upper region of the SQL Editor. The results of the statement are displayed in a table view in the lower region. In this example, the ``Counselor`` table displays. Note t [...] +4. To verify that the new record has been added to the ``Counselor`` table, in the Database Explorer, right-click the ``Counselor`` table node and choose View Data. A new SQL Editor pane opens in the main window. When you choose View Data, a query to select all the data from the table is automatically generated in the upper region of the SQL Editor. The results of the statement are displayed in a table view in the lower region. In this example, the ``Counselor`` table displays. No [...] image::images/sql-results.png[] @@ -218,10 +242,11 @@ When you click Yes in the Confirm Object Deletion dialog box, the table nodes ar To run the SQL script on ``MyNewDatabase`` : 1. Choose File > Open File from the IDE's main menu. In the file browser navigate to the location where you previously saved ``ifpwafcad.sql`` and click Open. The script automatically opens in the SQL Editor. -2. -Make sure your connection to ``MyNewDatabase`` is selected from the Connection drop-down box in the toolbar at the top of the Editor. +2. Make sure your connection to ``MyNewDatabase`` is selected from the Connection drop-down box in the toolbar at the top of the Editor. image::images/connection-drop-down.png[] + +[start=3] 3. Click the Run SQL (image::images/run-sql-button.png[]) button in the SQL Editor's task bar. The script is executed against the selected database, and any feedback is generated in the Output window. 4. To verify changes, right-click the ``MyNewDatabase`` connection node in the Runtime window and choose Refresh. The Refresh option updates the Database Explorer's UI component to the current status of the specified database. Note that the two new tables from the SQL script now display as a table nodes under ``MyNewDatabase`` in the Database Explorer. 5. Choose View Data from the right-click menu of a selected table node to see the data contained in the new tables. In this manner, you can compare the tabular data with the data contained in the SQL script to see that they match. @@ -229,3 +254,4 @@ image::images/connection-drop-down.png[] == Conclusion This concludes the Connecting to a MySQL Database tutorial. This document demonstrated how to configure MySQL on your computer and set up a connection to the database server from NetBeans IDE. It also described how to work with MySQL in the IDE's Database Explorer by creating new database instances and tables, populating tables with data, and running SQL queries. + --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists