The NetBeans E-commerce Tutorial - Setup Instructions
This tutorial needs a review. You can edit it in GitHub following these contribution guidelines. |
Tutorial Contents
If you want to follow a tutorial unit without having completed previous units, you need to perform some preliminary steps in order to set up your development environment.
-
Set up your MySQL database server. Follow the steps outlined in: Communicating with the Database Server.
-
Create the
affablebean
schema on the database server, and populate the database with sample data:-
Click on affablebean.sql and copy (Ctrl-C; ⌘-C on Mac) the entire contents of the file.
-
Open the IDE’s SQL editor. In the Services window (Ctrl-5; ⌘-5 on Mac), right-click the
affablebean
database connection ( ) node and choose Execute Command.
-
The IDE’s SQL editor opens.
-
Paste (Ctrl-V; ⌘-V on Mac) the entire contents of the
affablebean.sql
file into the editor.
-
Click the Run SQL ( ) button in the editor’s toolbar. The script runs on your MySQL server. Tables are generated for the database, and sample data is added to the
product
andcategory
tables.
-
Create a connection pool and JDBC resource on GlassFish.
-
In the Services window (Ctrl-5; ⌘-5 on Mac), expand the Servers > GlassFish Server 3 node and choose Properties. In the Servers window that displays, make sure the 'Enable JDBC Driver Deployment' option is selected. If your project requires the MySQL Connector/J driver, this option will ensure that the driver is deployed to GlassFish when your project is deployed. (If the server is already running, you’ll need to restart the server.)
-
In the Services window, right-click the GlassFish Server 3 node and choose Start.
-
Once the server is running, right-click the GlassFish Server 3 node and choose View Admin Console.
-
Log into the console (default username/password is:
admin/adminadmin
). -
In the Admin Console, in the Tree on the left, expand the Resources > JDBC node, then click the Connection Pools node.
-
In the Connection Pools interface, click the New button, and enter the following details:
-
Name:
AffableBeanPool
-
Resource Type:
javax.sql.ConnectionPoolDataSource
-
Database Vendor:
MySql
-
-
-
Click Next. Accept all defaults and click Finish.
-
In the Connection Pools interface, click on your newly created
AffableBeanConnectionPool
to make the following change under the General tab:-
Datasource Classname:
com.mysql.jdbc.jdbc2.optional.MysqlDataSource
-
-
Click Save.
-
Click the Additional Properties tab and ensure that the following three properties have been set. (There may be other properties listed - these are default settings, however the following three must be set manually.)
-
User:
root
-
Password:
nbuser
-
URL:
jdbc:mysql://localhost:3306/affablebean
-
-
Click Save.
-
Click the General tab, then click Ping. You should see a message indicating that the ping succeeded. The
AffableBeanPool
connection pool can now connect to your MySQL database server.
-
In the Admin Console’s Tree in the left column, click the Resources > JDBC > JDBC Resources node. The JDBC Resources interface opens in the main window.
-
Click the New button to create a new JDBC resource, then enter the following details:
-
JNDI Name:
jdbc/affablebean
-
Connection Pool:
AffableBeanPool
-
-
Click OK.
You have set up the MySQL server and can connect to it from the IDE’s Services window. You created a database named affablebean
, and populated the database’s product
and category
tables with sample data. You then started the GlassFish server, and created a connection pool that enables the server to connect to the affablebean
database. Finally, you created a JDBC resource which your application can use to reference the server’s connection pool.
You can now open and run any of the project snapshots provided for you in the tutorial units.