Developing Web Applications with Oracle ADF Essentials - Sten E. Vesterli - E-Book

Developing Web Applications with Oracle ADF Essentials E-Book

Sten E. Vesterli

0,0
39,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

With ADF, Oracle gives you the chance to use the powerful tool used by Oracle's own developers. Modern enterprise applications must be user-friendly, visually attractive, and fast performing. Oracle Fusion Applications are just that; but to get the desired output you need proven methods to use this powerful and flexible tool to achieve success in developing your enterprise applications.
"Developing Web Applications with Oracle ADF Essentials" explains all you need to know in order to build good-looking, user-friendly applications on a completely free technology stack. It explains the highly productive, declarative development approach that will literally have your application running within a few hours, as well as how to use Java to add business logic.
"Developing Web Applications with Oracle ADF Essentials" tells you how to develop and deploy web application applications based on the highly productive and free Oracle ADF Essentials framework. You will first learn how to build business services on top of database tables, and then how to easily build a web application using these services. You will see how to visually design the flow through your application with ADF task flows, and how to use Java programming to implement business logic. Using this book, you can start building and deploying advanced web applications on a robust, free platform quickly.
Towards the end, you will be ready to build real-world ADF Essentials applications and will be able to consider yourself an ADF Essentials journeyman.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 278

Veröffentlichungsjahr: 2013

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Developing Web Applications with Oracle ADF Essentials
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Instant Updates on New Packt Books
Preface
The prescription
Off-label use
Allergies
What's not there
The sample application
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. My First ADF Essentials Application
Getting ready
Installing MySQL
MySQL installation
Configuring
Changing MySQL options
Does it work?
Modifying some data
Installing Java Development Kit and GlassFish
Installing JDK 7
Installing GlassFish
GlassFish installation
Setting up the domain
Does it work?
Installing the MySQL connector in GlassFish
Adding a DataSource to GlassFish
Installing ADF Essentials
Getting ADF Essentials
Installing the ADF Share libraries in GlassFish
Setting the GlassFish JVM parameters
Does it work?
Installing JDeveloper
JDeveloper or Eclipse?
Which JDeveloper?
JDeveloper installation
Installing the MySQL Connector in JDeveloper
Installing the GlassFish Server Extension
Connecting to the GlassFish server
Building a simple ADF Essentials application
Creating the application
Database
Business service
Model layer
Controller layer
View layer
Getting ready to deploy
DataSource
Application module configuration
Change platform
Running your first ADF Essentials application
Can it run faster?
Setting up WebLogic for MySQL
Adding a DataSource to WebLogic
Running your first ADF Essentials application again
Summary
2. Creating Business Services
Business service possibilities
ADF Business Components
Starting the example application
How ADF business components work
Building your own foundation
Building framework extension classes
Using framework extension classes
Building entity objects for the example application
Preparing to build
Running the wizard
Examining the result
Setting the labels
Autogenerated values
Cleaning up the data types
Cleaning up the associations
Deleting superfluous associations
Fixing wrong associations
Removing invalid references from entity objects
Building view objects
The storyboard
Building the customer view object
Building the rental view object
Creating a view link
Application module
Testing business components
Summary
3. Creating Task Flows and Pages
Building task flows
Bounded and unbounded task flows
Pages and fragments
Task flow templates
Example application
Building the Rent DVD task flow
Building the Return DVD task flow
Memory scopes
Other elements of task flows
Building pages
Using templates
Facet definitions
Page fragment template
Page template
Example application
Building the customer search page
Building the Return DVD page
An alternative – ADF query panel
Building the Rent DVD page
Building a master page
Running the page
Using data bindings
Showing a customer on a page
Showing customer rentals on a page
Adding navigation
Summary
4. Adding Business Logic
Adding logic to business components
Logic in entity objects
Overriding accessors
Working with database triggers
Overriding doDML()
Data validation
Declarative validation
Regular expression validation
Groovy scripts
Method validation
Logic in view objects
Overriding accessors
Change view criteria
Logic in application modules
Adding logic to the user interface
Adding a bean method to a button
Adding a bean to a task flow
Accessing UI components from beans
Accessing the binding layer
Working with attribute values
Working with operations
Working with whole datasets
Showing messages
Example application
Registering a rental
Creating a bean
Mapping the fields
Establishing bindings
Writing the code
Registering a return
Adding a column and a button
Creating a bean
Mapping the table
Creating a view object method
Publishing your method
Establishing bindings
Writing the bean code
Marking items returned today
Creating a transient attribute
Binding the new attribute
Coding the attribute return value
Using the attribute value
Other ideas
Summary
5. Building Enterprise Applications
Structuring your code
Workspaces and projects
The workspace hierarchy
The directory structure
Using version control
Working with ADF libraries
Creating ADF libraries
Releasing ADF libraries
Using ADF libraries
Example application
Creating the Master Application Workspace
Creating the workspace
Adding to source control
Creating the ADF library folder
Creating the CommonCode workspace
Creating the workspace
Recreating the framework extension classes
Check your JDeveloper preferences
Adding to source control
Creating the ADF library
Releasing the ADF library
Creating the CommonUI workspace
Creating the workspace
Creating the templates
Adding an ADF library
Adding to source control
Creating and releasing the ADF library
Creating the CommonModel workspace
Creating the workspace
Adding an ADF library
Creating the entity objects
Adding to source control and creating the ADF library
Creating the RentDvd subsystem workspace
Creating the workspace
Adding ADF libraries
Creating the view object
Creating the application module
Creating the task flow and page fragment
Adding a binding
Adding the business logic
Remaining work
Creating the ReturnDvd subsystem workspace
Creating the workspace
Adding ADF libraries
Creating the Customer view object
Creating the Rental view object
Creating a View Link
Creating an application module
Creating the task flow
Creating the Customer Search Page Fragment
Creating the Rentals Page Fragment
Registering a return
Remaining work
Finishing the Master Application Workspace
Adding the ADF libraries
Create the master page
Summary
6. Debugging ADF Applications
ADF logging
Creating a logger
Adding log statements
Business logging
JDeveloper shortcuts
Reading the logs
Logging in GlassFish
Controlling domain logging
Controlling individual loggers
Debugging in JDeveloper
Debugging code
Understanding the ADF lifecycle
Debugging task flows
Debugging into ADF libraries
Creating a source directory
Creating a source JAR file
Including the source in the master application
Placing a breakpoint in an ADF library
Debugging into the ADF source code
Summary
7. Securing an ADF Essentials Application
Apache Shiro basics
Getting the software
Installing the packages in your application
Configuring your application for Shiro
Advanced Shiro
User database
Form-based authentication
The login page
The login bean
The login method
The user filter
The Shiro configuration
Accessing the user
Implementing authorization
Can I see some ID, please?
Are you a member, Sir?
Disabling elements
Removing elements
Securing task flows
Summary
8. Build and Deploy
Creating a build script
Creating the script
Deploying a single application
Building the master application
Starting point
Building the application EAR file
Building all the subsystems
Copying all ADF libraries
Putting it all together
Automated deployment to GlassFish
Deploying from the command line
Deploying from Ant
Integrating other functionality in your build
Preparing to go live
Cleaning up your code
Database connections
Deployment platforms
Print statements
Tuning your ADF application
Summary
Index

Developing Web Applications with Oracle ADF Essentials

Developing Web Applications with Oracle ADF Essentials

Copyright © 2013 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: August 2013

Production Reference: 1160813

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78217-068-6

www.packtpub.com

Cover Image by Artie Ng (<[email protected]>)

Credits

Author

Sten E. Vesterli

Reviewers

Eugene Fedorenko

Amr Gawish

Dimitrios Stasinopoulos

Acquisition Editors

Erol Staveley

Antony Lowe

Lead Technical Editor

Madhuja Chaudhari

Technical Editors

Anita Nayak

Pragati Singh

Vrinda Nitesh Bhosale

Project Coordinator

Apeksha Chitnis

Proofreader

Paul Hindle

Indexer

Hemangini Bari

Graphics

Ronak Dhruv

Production Coordinator

Aditi Gajjar

Cover Work

Aditi Gajjar

About the Author

Sten E. Vesterli picked up Oracle development as his first job after graduating from the Technical University of Denmark, and he hasn't looked back since. He has worked with almost every development tool and server Oracle has produced in the last two decades, including Oracle ADF, JDeveloper, WebLogic, SQL Developer, Oracle Portal, BPEL, Collaboration Suite, Designer, Forms, Reports, and even Oracle Power Objects.

He started sharing his knowledge with a conference presentation in 1997, and has since given more than 100 conference presentations at Oracle OpenWorld, ODTUG, IOUG, UKOUG, DOAG, and other user group conferences around the world. His presentations are highly rated by the participants, and in 2010, he received the ODTUG Best Speaker award.

He has also written numerous articles, participated in podcasts, and has written the books Oracle Web Applications 101, The McGraw-Hill Companies and Oracle ADF Enterprise Application Development – Made Simple, Packt Publishing. You can find his blog at www.vesterli.com and follow him on Twitter as @stenvesterli.

Oracle has recognized Sten's skills as an expert communicator on Oracle technology by awarding him the prestigious title of Oracle ACE Director, which is carried by less than 100 people in the world. He is also an Oracle Fusion User Experience Advocate and is a part of the Oracle Usability Advisory Board and participates in the Oracle WebLogic Partner Council.

Based in Denmark, Sten is a partner in the Oracle consulting company Scott/Tiger, where he works as a Senior Principal Consultant. When not writing books or presenting, he is helping customers choose the appropriate technology for their needs, teaching, mentoring, and leading development projects. In his spare time, Sten enjoys triathlons, and he completed his first Ironman in 2012.

Acknowledgement

As an ADF enthusiast, I'd like to thank Oracle for finally making a free version of Oracle ADF available. With it's high productivity and advanced features, ADF Essentials has the potential to become the standard way of writing data-handling applications. With this book, I hope to help that become a reality.

Others have gone before me in the quest to get the combination of ADF Essentials, MySQL, and GlassFish to work together. I'd especially like to thank Markus Eisele, Duncan Mills, Chris Muir, Jobinesh Purushothaman, Bauke Scholtz, and Shay Shmeltzer, whose work with ADF, Apache Shiro, MySQL, and GlassFish I have benefited from.

I also appreciate the efforts of the people at Packt Publishing who have been supporting this project, as well as my reviewers who have improved the book with their excellent questions and suggestions.

Finally, I'd like to thank my lovely wife for her love, support, and understanding for yet another book project.

About the Reviewers

Eugene Fedorenko is a senior analyst with extensive experience and management skills. He works for the Ukrainian software company CS Integra. The company focuses on banking software and is a leader in the local market. The company has been an Oracle Platinum partner since 2010 and it was rewarded as the Best Independent Software Vendor in the Eastern Europe region. Eugene graduated from the Kharkiv Aviation Institute in 1999 with an M.Sc. in Computer Science. He began his career in the company in 2000 as a developer. Currently, he is a senior analyst and he is in charge of running projects connected to Oracle Application Development Framework. He is the author of the ADF practice blog http://adfpractice-fedor.blogspot.com and a member of the ADF Enterprise Methodology Group.

Amr Gawish is a Senior Oracle Fusion Middleware Consultant. He is a certified WebCenter Portal and Oracle SOA implementation specialist. He has over five years of experience with the Oracle Middleware stack. He holds a Bachelor's degree in Math and Computer Sciences from Al-Azhar University in Egypt, and he has been involved in many ADF, WebCenter, and SOA projects. He currently works at infoMENTUM, which is an Oracle Gold Partner and a leading company in Oracle Fusion Middleware, and it is the first company to be specialized in WebCenter (both Content and Portal) in the EMEA region. It's what Amr calls "a place where innovation comes true!"

Amr is also currently authoring a book about ADF Faces called Oracle ADF Faces Cookbook, Packt Publishing.

I'd like to thank my wife for helping and encouraging me to complete the review in time, and my daughter for always bringing a smile to my face.

Dimitrios Stasinopoulos is a Certified Application Development Framework Implementation Specialist with more than six years of experience in Oracle Fusion Middleware and, more specifically, in ADF BC 11g. Dimitrios currently works as an Oracle Fusion Middleware Consultant, mainly focusing on Oracle ADF, at e-DBA Ltd., an Oracle Platinum Partner. Dimitrios has worked in several Oracle ADF projects in various positions, from developer to architect, and he also enjoys teaching and talking about Fusion Middleware.

In his spare time, Dimitrios is helping the ADF community by answering technical questions in the Oracle ADF and JDeveloper forum, and he also maintains a blog where he posts his findings and ideas: dstas.blogspot.com.

Dimitrios holds a B.Sc. degree in Computer Science from the Technological Educational Institution of Larissa, Greece.

www.PacktPub.com

Support files, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. 

Why Subscribe?

Fully searchable across every book published by PacktCopy and paste, print and bookmark contentOn demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

Instant Updates on New Packt Books

Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.

Preface

Oracle ADF is the most productive framework available today for building data-handling web applications. With just a little training (like you can get from this book), you will be able to build fully-functional applications to meet a wide variety of needs.

Until September 2012, this powerful tool was reserved for organizations and projects able to pay for an Oracle WebLogic Server license, which is not quite cheap. But that month, after years of badgering by ADF enthusiasts, Oracle finally decided to make a free, slightly limited version of Oracle ADF available to everyone.

This means the fastest, easiest, and cheapest way of building a data-handling application today is with the technology stack described in this book:

The free MySQL databaseThe free GlassFish application serverThe free ADF Essentials toolkitThe free JDeveloper development tool

The prescription

When pharmaceutical companies develop drugs, they are targeting specific ailments or situations. Similarly, IT development platforms and frameworks target specific use cases. And the "sweet spot" for the ADF framework is data-handling applications.

What is a data-handling application? It is an application whose primary function is to gather data, process them, and display them back to the user as tables or graphs. Examples of data-handling applications are membership databases, project and task management, or accounting programs.

With very powerful declarative features, you can build most of your application without having to write any code, and the advanced user interface components make it easy to build an attractive user interface including interactive graphical displays of your data.

Off-label use

After release, some drugs are found to be potentially useful for other conditions than those for which they were developed and tested. This is called "off-label use" — using the drug for something that it was not intended for.

A similar situation occurs in the development of IT systems –– developers choose a tool that is a brilliant choice for one type of applications and try to use it for other types.

The classic case of "off-label use" of ADF is to build an application where you require absolute control over every pixel and every interaction. Such control is often possible to achieve with ADF, but it takes a big effort and requires deep modifications to the core of the framework.

Allergies

In medicine, some people are allergic to certain medicines and should not be given them.

Similarly, there are some types of highly interactive applications like games or photo editing that are definitely unsuited for ADF.

What's not there

ADF Essentials contains everything you need to build a data-handling application –– but of course, there has to be some additional features only available to enterprise customers with a full ADF license.

Some of the things not included in ADF Essentials include ADF Mobile, ADF Security (which is based on Oracle Platform Security Services, available only in WebLogic), Web Service Data Controls, ADF Desktop Integration, and so on. Refer to the ADF Essentials "Frequently Asked Questions" document for the full list.

However, it is worth repeating that everything you need in order to build data-handling applications is there. Actually, everything is there –– the restriction is only a legal and licensing issue.

The sample application

Throughout this book, a sample application for a DVD rental shop is built. You can follow along in JDeveloper as you read, learning ADF hands-on.

The data model is the standard sakila database schema that comes with MySQL. The part we use consists of the customer, film, inventory, and rental tables –– their relationship looks as shown in the following diagram:

We will build three application screens: one simple screen for registering a rental, and two connected screens for searching for a customer and registering a return. These two screens look as shown in the following diagram:

What this book covers

Chapter 1, My First ADF Essentials Application, shows you how to install all the software and build a very simple application to prove that everything works.

Chapter 2, Creating Business Services, describes what Business Components are and how they are used in the example application. No code required!

Chapter 3, Creating Task Flows and Pages, shows you how to build ADF task flows that control the flow of your application and how to build the ADF pages where the user interacts with the data. Still no code required!

Chapter 4, Adding Business Logic, explains how to add business logic to your application –– this is where you'll have to write some actual Java code to implement functionality that ADF does not offer declaratively.

Chapter 5, Building Enterprise Applications,demonstrates how you go about building a larger application, using subsystems and ADF libraries to divide a big application into more manageable parts. We'll quickly build the whole DVD rental application again in this chapter using proper enterprise methodology.

Chapter 6, Debugging ADF Applications, shows you how to use ADF logging and debugging features to troubleshoot any problems you might experience during your ADF development.

Chapter 7, Securing an ADF Essentials Application,implements Apache Shiro to secure your application. Remember that there were some ADF-specific security features not part of ADF Essentials? This chapter shows you a fully-functional alternative.

Chapter 8, Build and Deploy,demonstrates how to use Apache Ant to create build scripts that compile, build, and deploy an entire enterprise application, including subsystems and ADF libraries.

What you need for this book

This book uses the following software:

MySQL database version 5.6GlassFish application server 3.1 ADF Essentials 11.1.2.4JDeveloper 11.1.2.4

Chapter 1, My First ADF Essentials Application, explains where to get the software, how to install it, and how to configure all the parts to work together.

Who this book is for

This book is for every web developer who wants to build data-handling applications quickly and efficiently. The book does not require any preconditions –– even beginners can use the powerful declarative features of ADF to build basic applications completely without programming.

Most real-life applications will of course require some programming to implement the business logic that is specific to your application. ADF uses Java to implement business logic, so a basic understanding of Java programming is required for most applications. A bit of knowledge about web applications in general will also be beneficial.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the erratasubmissionform link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. My First ADF Essentials Application

In this chapter, we will install all the necessary (free!) software that we will be using throughout the book to build applications using Oracle Application Development Framework (ADF). We'll need:

A databaseJava Development Kit and an application serverThe Oracle ADF Essentials librariesA development tool

For the purposes of this book, we will be using the popular and free MySQL database. However, you can run Oracle ADF Essentials applications on any other SQL database—so if you're a PostgreSQL fan, you don't have to change. You can also use commercial databases—Oracle is offering Oracle Database Express Edition if you are looking for a free version of an enterprise product.

Tip

Don't plan on running Oracle Database Express Edition directly on your development machine if it is 64-bit Windows—this is not supported and won't work. To run Oracle XE, you'll either need Linux, an old 32-bit Windows install, or run your database inside a 32-bit Windows virtual machine.

Similarly, you can run your ADF Essentials application on any JEE application server. This book will describe how to use GlassFish, but you could also use other open source JEE servers like JBoss or commercial offerings like Oracle WebLogic.

As our development tool, we will be using Oracle's preferred development tool, Oracle JDeveloper. This free tool is currently the only supported way of building Oracle ADF Essentials applications, but Oracle is working on supporting ADF Essentials as part of their Oracle Enterprise Pack for Eclipse (OEPE) product.

Tip

With Eclipse and Oracle Enterprise Pack for Eclipse, you can already build ADF applications for WebLogic. However, the tool does not yet support building applications for ADF Essentials.

Getting ready

To simplify the instructions in this book, you should create a directory called adfessentials and install everything there.

On Windows, place this directory in the root of your C: drive as C:\adfessentials.

On Mac/Linux, place this directory in the root of your filesystem as /adfessentials. You will typically be prompted for a system administrator or root password when creating the directory.

Installing MySQL

The MySQL server exists in both a Community Server edition and an Enterprise Edition. The Enterprise Edition is the commercial version that has additional features and a price tag—in this book, we will use the free Community Server edition Version 5.6.12. This can be downloaded from http://dev.mysql.com/downloads/mysql.

Note

Would you like support with that?

Now is a good time to think about whether you want your installation to be commercially supported. If you are setting up a development environment or just want to run a membership application for your local little league baseball team, you probably don't need commercial support and can go with the open source/community options.

On the other hand, if you are setting up a production environment, think about whether you or someone else in your organization feels confident that they can handle any issues that might occur. If you would like to be able to call on the friendly people from Oracle Support to help you, you need to set up the commercial version and purchase a support contract from Oracle.

If you choose the Windows platform, you will be given the option to download the MySQL Installer MSI package as shown in the following screenshot:

When you click on the Download link, you will be taken to a page where you can select from two MSI Installer packages as shown in the following screenshot:

Choose the larger one to get everything in one download. The smaller option means that you download only the installer program first, and this program will then download the rest of the software.

If you are running Mac OS X, you have an option to select either a compressed TAR file or a DMG installer as shown in the following screenshot:

For the easiest installation, choose the DMG installer file that matches your OS X version and architecture. If you have a fairly recent Mac, you should choose OS X 10.7, 64-bit.

If you are running Linux, choose your distribution from the Platform options (or Linux – Generic if your distribution is not listed), and then choose the download that matches your Linux version and architecture (32- or 64-bit).

Once you have chosen your download, you will be prompted to sign up for a free Oracle Web account (or log in with an existing account) when you click on the Download link. You will need this account in order to download the ADF Essentials software and JDeveloper, and probably later for other downloads as well.

MySQL installation

This section will walk you through the installation of the MySQL database on Windows – if you are running another operating system, the process is similar.

Tip

Some installation options of some Linux distributions install MySQL by default. If you are running Linux, you might want to check if you already have MySQL.

Start the installer, click on OK to any warnings about installing software and changing your machine, and choose Install MySQL Products. Read and accept the license agreement and allow it to check for later versions of the software.

For the purposes of this book, you can simply choose a Developer Default setup type when prompted. If you already know MySQL and have specific ideas about your installation, feel free to change the options.

Change the installation path to C:\adfessentials\MySQL\product and the data path to C:\adfessentials\MySQL\data.

Note

On Mac and Linux, the installer might simply decide to place the software and data in /usr/local. That's fine, too.

In the Check Requirements step, you may be prompted to install various additional packages—simply accept this. If you are told that you are missing various versions of the Python programming language, you can just click on Execute a few times to acknowledge the warnings.

Note

The Developer Default installation includes database connectors for Python, but if you are not using Python, they can't be installed. That's OK.

Once you are done with this step, the installer starts installing the actual MySQL software as shown as follows:

Configuring

When the software is installed, you can click on Next a few times to start the configuration. The first screen looks like this:

On this screen, you can leave the defaults:

Development MachineEnable TCP/IPPort Number 3306Open Firewall for network access

In step 2 shown in the following screenshot, you are asked to provide a root password for the database. You can always create separate users later.

Tip

If this is a non-critical development workstation, and you want to be sure that you have the password written down, feel free to use this example password: ADFsecret/13.

Tip

The default installation on Mac and Linux sets a blank root password, which is probably a bit too relaxed. To set the password on Mac/Linux, execute the following command:

/usr/local/mysql/bin/mysqladmin –u root –p password

Press return when prompted for a password (the prompt is for the old, empty password) and then provide a new password twice.

In step 3, you are prompted for a Windows service name as shown in the following screenshot:

You can leave the defaults on this screen.

When you click on Next, the configuration of MySQL runs. When this is complete, click on Next to install the samples and examples and then finish the installation.

Changing MySQL options

JDeveloper generates code with two vertical bars (|| or pipes) for string concatenation, and while this is valid SQL92, it is not supported in a default MySQL configuration. To enable this in MySQL, find the MySQL configuration file my.ini in the database directory (for example, C:\adfessentials\MySQL\data).

Search for a line starting with sql_mode=. If such a line exists, add a comma after the existing value and then the keyword PIPES_AS_CONCAT. If there is no sql_mode line, add the following:

sql_mode=PIPES_AS_CONCAT

If you come from an Oracle background, you might want to set sql_mode=ORACLE instead—this sets PIPES_AS_CONCAT and a couple of other settings to make MySQL behave more Oracle-like.

You will need to restart the MySQL database in order for this change to take effect. On Windows, you can open the Control Panel, choose Administrative Tools, and then Services. Find the MySQL56 service and choose Action | Restart. You can also restart the database from the MySQL Workbench by double-clicking on your database in the Server Administration column to the right.

Does it work?

Once you have your Sakila database installed, you can start the MySQL Workbench from the Start menu. You should see Local instance MySQL56 or similar to the left under the SQL Development heading, as shown in the following screenshot:

You can double-click on this and provide your root password to connect to the database. If an SQL Editor window opens with various schemas to the left (including your Sakila database) as shown in the following screenshot, your installation was successful:

If you prefer to use a command line, you can start the MySQL 5.6 Command Line Client from the Start menu, provide your root password, and type the following command:

show databases;

If you see a couple of databases as in the following screenshot, your MySQL server is running correctly:

The MySQL command line can also be started from a command prompt by running the following command:

C:\adfessentials\MySQL\product\bin\mysql –u root -p

This attempts to log in as user root and prompts you for the password.

Tip