Developing Web Applications with Oracle ADF Essentials
上QQ阅读APP看书,第一时间看更新

Can it run faster?

Because the deployment from JDeveloper to GlassFish currently takes quite a long time, many developers choose to run their new code first in the WebLogic server that is pre-integrated into JDeveloper. If you set up WebLogic for MySQL, a simple application like the preceding should be able to start in 20-30 seconds instead of several minutes.

Tip

Hopefully, the deployment speed to GlassFish will be improved in the future. Check out the http://www.adfessentials.com for any tips about speeding up deployment that have been discovered after the publication of this book.

Setting up WebLogic for MySQL

If you want to run MySQL applications in the built-in WebLogic server, you first need to copy the MySQL Connector JAR (mysql-connector-java-5.1.25-bin.jar) to a directory where WebLogic can find it. A good choice is the directory for external libraries in the JRA installation: C:\adfessentials\middleware111240\jdk160_24\lib\ext.

Tip

If you are familiar with WebLogic, you should be able to place the MySQL connector in the WebLogic default domain lib directory. However, in JDeveloper 11.1.2.4, this does not work. Either use the preceding directory or modify the domain startup scripts.

Adding a DataSource to WebLogic

Once you have the driver installed, you need to define a datasource with the right name like you did earlier in the chapter for GlassFish.

First, in JDeveloper, start the built-in WebLogic server with the command Run | Start Server Instance. The first time you start the server, you will be prompted for a password to the default domain. Watch the messages in the log window until you see the following command:

<Server started in RUNNING mode>

Then, open a web browser and type in the address http://localhost:7101/console. Log in with the admin user and the password you provided. After a little while, the WebLogic console window opens.

Expand the Services node under Domain Structure to the left and select the Data Sources node. Click on New | Generic Data Source. Give your datasource a Name (SakilaDS) and a JNDI Name (jdbc/SakilaDS), and choose Database Type as MySQL. In the next two steps, just leave the defaults. On the Connection Properties page, provide your connection details:

  • Database Name: sakila
  • Host Name: localhost
  • Port: 3306
  • Database User Name: root
  • Password and Confirm Password: Your database root password, for example, ADFsecret/13

On the following screen, click on Test Configuration. You should see Connection test succeeded.

Click on Next (not Finish) and check the checkbox next to DefaultServer. Then, click on Finish.

Tip

In WebLogic, a JDBC driver definition is by default not connected to any server. If you forget to check the checkbox associating the SakilaDS datasource with the DefaultServer, the server can't connect to the database.

Running your first ADF Essentials application again

To run your first ADF Essentials application in the built-in WebLogic, server simply right-click on FilmPage in the Application Navigator and choose Run. The application will automatically be re-built, deployed to the built-in WebLogic server, and opened in a browser.