Sample Web Application - Tirasa/OpenJPA-Azure GitHub Wiki

Introduction

This page describes how to setup and run the sample application provided to try-out the integration between Apache OpenJPA and Windows Azure SQL Database federations.

Pre-requisites

  1. Download JDBC driver for MS SQL Server and install it in your local maven repository by executing the following command
mvn install:install-file \
-Dfile=[absolute path to sqljdbc4.jar] \
-DartifactId=sqljdbc4 \
-DgroupId=com.microsoft.sqlserver \
-Dversion=4.0 \
-Dpackaging=jar \
-DgeneratePom=true 
  1. Subscribe your own Windows Azure account (90-day free trial is good as well)

  2. Create the federated database:

  3. Access to Windows Azure portal by using your windows live id.

  4. On the left menu, click on Database and create a new database called FEDDB.

  5. Always under Database section, expand your subscriptions tree, and click on the the database instance FEDDB.

  6. On the top menu, click on Manage in order to manage the database instance created above.

  7. Log-in to MS SQL Azure management portal by using the credentials specified during the database creation (retrieve username by looking at the database connection string retrievable on the Windows Azure portal, under FEDDB management page, at the Connection Strings link provided by the right menu).

  8. Create new query and perform the following SQL statements.

CREATE FEDERATION FED_1 (range_id BIGINT RANGE)
GO
ALTER FEDERATION FED_1 SPLIT AT (range_id=5)
GO

Build the project, Run & Try-Out

  1. Get your local copy of the sample web application
$ git -b sample clone https://github.com/Tirasa/OpenJPA-Azure.git openjpa-azure-sample
$ cd openjpa-azure-sample
  1. Configure src/main/resources/persistence.properties by providing:
  • full JDBC URL (jpa.url)
  • configured user name (jpa.username)
  • configured user password (jpa.password)
  1. Run the following command
mvn clean package cargo:run
  1. Browse http://localhost:8080/.
⚠️ **GitHub.com Fallback** ⚠️