Archive for the ‘glassfish’ Category

TOTD #122: Creating a JPA Persistence Unit using NetBeans 6.8

Февраль 10th, 2010

Taking TOTD #121 forward, this blog explains how to create a JPA Persistence Unit for a MySQL sample database and package it as a library. This JAR file can then be easily included in other web applications.

Lets get started!

  1. Configure GlassFish for using the MySQL sample database (sakila) as described in TOTD #121.
  2. Add the GlassFish instance in NetBeans IDE using "Services" panel.
  3. Create JPA entities using NetBeans IDE.
    1. Create a Java class library:



      Our ultimate goal is to create a reusable JAR file and that's why this project type is chosen.
    2. Specify the name of project as "SakilaPU":


    3. Right-click on the project and select "New", "Entity Classes from Database ..." to initiate the process of entity generation:

    4. Choose the database connection as:



      If not configured, then can be easily done by clicking on "New Database Connection ..." in the list box.
      1. Click on "Add All >>" to generate the mapped JPA entities for all tables and views.
      2. The views do not have primary keys and will need to be appropriately annotated (described later).
      3. Click on "Next >".
    5. Give the package name as:



      and specify the package name as "sakila". Click on "Create Persistence Unit ...".
    6. Change the default PU name from "SakilaPUPU" to "SakilaPU":



      and click on "Finish". Notice that "EclipseLink", the Reference Implementation of JPA 2.0, is used as the persistence library.
    7. Add "@javax.persistence.Id" annotation to the following class/field combination:
      Class Field
      sakila.SalesByFilmCategory category
      sakila.ActorInfo actorId
      sakila.FilmList fid
      sakila.CustomerList id
      sakila.NicerButSlowerFilmList fid
      sakila.StaffList id
      sakila.SalesByStore store

      This is required because none of the "views" are defined with a primary key.
    8. Right-click on the project and select "Clean & Build". This generates "dist/SakilaPU.jar" and the structure looks like:



This JAR file can now be included in any web application. The pre-built JAR file can also be downloaded here. The key items to note about this pre-built JAR:

  • Persistence Unit Name: "SakilaPU"
  • All classes are in "sakila.*" package.
  • Each class has a pre-defined "<CLASS-NAME>.findAll" named query that returns all elements from the underlying view/table.
  • Can be easily added in "WEB-INF/lib" directory of your web application.

Even though this blog uses a MySQL sample database, these steps can be easily followed for any other database such as Oracle or JavaDB.

Technorati: totd javaee glassfish v3 jpa eclipselink persistenceunit mysql sakila netbeans


PlanetMySQL Voting: Vote UP / Vote DOWN

TOTD #121: JDBC resource for MySQL and Oracle sample database in GlassFish v3

Февраль 9th, 2010

This blog clearly explains how to configure the MySQL sample database (sakila) with GlassFish. Even though the instructions use a specific database but should work for other databases (such as Oracle, JavaDB, PostgreSQL, and others) as well. The second half of the blog provide specific syntax for the Oracle sample database.

  1. Download sakila sample database and unzip the archive.
  2. Install the database as described here - basically load and run "sakila-schema.sql" and "sakila-data.sql" extracted from the archive.
  3. Create a new MySQL user account using MySQL CLI Admin and assign the privileges
    1. Using "root" user (sudo mysql --user root)
      CREATE USER glassfish IDENTIFIED BY 'glassfish';
      GRANT ALL PRIVILEGES ON *.* TO 'glassfish'@'localhost' IDENTIFIED BY 'glassfish';
      FLUSH PRIVILEGES;
      
    2. Using "glassfish" user (sudo mysql --user glassfish)
      source sakila-schema.sql;
      source sakila-data.sql;
      
  4. Download Connector/J, unzip and copy "mysql-connector-java-5.x.x-bin.jar" to "glassfish/domains/domain1/lib/ext" directory.
  5. Start GlassFish server as:
    asadmin start-domain
    
    
  6. Create a JDBC resource
    1. Create JDBC connection pool as:
      asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource --restype javax.sql.DataSource --property "User=glassfish:Password=glassfish:URL=jdbc\:mysql\://localhost/sakila" jdbc/sakilaPool
      
    2. Test the JDBC connection pool as:
      asadmin ping-connection-pool jdbc/sakilaPool
      
    3. Create the JDBC resource as:
      asadmin create-jdbc-resource --connectionpoolid jdbc/sakilaPool jdbc/sakila
      

That's it!

Creating a JDBC resource for any other database requires the following updates to the steps mentioned above. Lets consider modifying these steps for the Oracle sample database.

  1. Use the client interface SQL*PLus and connect as:
    sqlplus "/ as sysdba"
    

    create user and grant the privileges as:
    CREATE USER glassfish IDENTIFIED BY glassfish DEFAULT tablespace users TEMPORARY tablespace temp;
    GRANT CONNECT TO glassfish IDENTIFIED BY glassfish;
    GRANT UNLIMITED TABLESPACE TO glassfish;
    GRANT CREATE TABLE TO glassfish;
    GRANT CREATE SEQUENCE TO glassfish;
    
  2. Copy the appropriate JDBC driver (ojdbc6.jar).
  3. Create the JDBC resource as:
    asadmin create-jdbc-connection-pool --datasourceclassname oracle.jdbc.pool.OracleDataSource --restype javax.sql.DataSource --property "User=hr:Password=hr:URL=jdbc\:oracle\:thin\:@localhost\:1521\:orcl" jdbc/hr
    asadmin ping-connection-pool jdbc/hr
    asadmin create-jdbc-resource --connectionpoolid jdbc/hr jdbc/hr
    

    as explained in TOTD #108.

Here are a few other related entries:

Technorati: totd javaee glassfish v3 jpa mysql sakila oracle


PlanetMySQL Voting: Vote UP / Vote DOWN

CAOS Theory Podcast 2010.02.05

Февраль 5th, 2010

Topics for this podcast:

*Matt Asay moves from Alfresco to Canonical
*GPL fade fuels heated discussion
*Apple’s iPad and its enterprise and open source impact
*Open source in data warehousing and storage
*Our perspective on Oracle’s plans for Sun open source

iTunes or direct download (32:50, 9.2 MB)


PlanetMySQL Voting: Vote UP / Vote DOWN

Summary of Post-Oracle Links and Changes

Февраль 2nd, 2010
ALT DESCR

This running entry collects key announcements related to Oracle's Acquisition of Sun; some from the Jan 27th event, some from companion webcasts, and some later announcements.

The main theme of the acquisition is "We're Changing the Way you Buy, Run and Manage Business Systems".

Main Entry Points:

From the Software Segment of the Strategy Webcast Series:

  • Jeet & Hasan on Java Strategy. Covers JavaFX, JavaSE, Blu-Ray, GlassFish, JavaCard, Developer Sites, JCP, JavaOne Java For Business.
  • Hasan Rizvi on Application Server. GlassFish, WebLogic, protecting investment in existing products, Oracle Application Grid, Grid Architecture, jRockit, Coherence, Tuxedo, OpenMQ, GlassFish WebStack and GF SpaceServer - and Liferay, Sun WebServer, Portal Server, Oracle WebCenter. Check slide 12 (and 6'12") for current level of details on WebLogic/GlassFish alignment.
  • Richard Sarwal and Steve Wilson on Oracle Enterprise Manager and xVM OpsCenter. Combined story covers discovery, provisioning, updating, monitoring - including for virtualized assets. Application-to-disk management.
  • OpenOffice, with Michael Bemmer. Open Source, name changes, Oracle value proposition, Web-Based version, JDeveloper support, Extensions, ODF-support, integration with other Oracle products.
  • Cloud with Richard Sarwal. A pretty good presentation covering IAAS, PAAS, SAAS; Private and Public Clouds; range from Silo > Grid > Private Cloud > Hybrid including Private and Public Cloud; cloud-in-a-box. Discontinuing the Sun public cloud offering but leveraging Sun's technology, including Q-Layer team for Oracle products that provide flexible, self-service, dynamic services.
  • Operating Systems by Edward Screven.

From the Systems Segment of the Strategy Webcast Series:

Other Links:

Additional Information - Oracle continues to update their site; see also:

Press, Analysts, Friends, Others:


PlanetMySQL Voting: Vote UP / Vote DOWN

New «Oracle and Sun Overview and FAQ»

Октябрь 28th, 2009

Oracle has updated their page on Oracle and Sun and it now includes a PDF entitled "Oracle and Sun Overview and FAQ".  Check it out for comments on many topics covering Sun's Hardware (SPARC, Storage, x86) and Software offerings, including NetBeans, OpenOffice, MySQL, OpenSource, VirtualBox and GlassFish.


PlanetMySQL Voting: Vote UP / Vote DOWN

NHIN Connect Using GlassFish and OpenESB

Октябрь 26th, 2009

The importance of information exchange in Health Care will continue to grow and the Federal Goverment has several projects to improve it, while also trying to reduce costs. And, as Bill wrote earlier in the year, Sun's Open Source has been actively engaged in this.

ALT DESCR

The goal of the National Health Information Network (NHIN) is to provide secure, nationwide, interoperable health information infrastructure that will connect providers, consumers, and others involved in supporting health and healthcare. And the CONNECT Gateway is intended to let the federal agencies connect to the NHIN.

Within the HHS, the ONC is the main entity that coordinates these efforts and it just has choosen Health Information Exchange Open Source (HIEOS) as a key portion of NHIN Connect.

And, HIEOS - developed by Vangent - is using several of our OpenSource components - see Architectural Diagram - including OpenESB and GlassFish, and MySQL.


PlanetMySQL Voting: Vote UP / Vote DOWN

NHIN Connect Using GlassFish and OpenESB

Октябрь 26th, 2009

The importance of information exchange in Health Care will continue to grow and the Federal Goverment has several projects to improve it, while also trying to reduce costs. And, as Bill wrote earlier in the year, Sun's Open Source has been actively engaged in this.

ALT DESCR

The goal of the National Health Information Network (NHIN) is to provide secure, nationwide, interoperable health information infrastructure that will connect providers, consumers, and others involved in supporting health and healthcare. And the CONNECT Gateway is intended to let the federal agencies connect to the NHIN.

Within the HHS, the ONC is the main entity that coordinates these efforts and it just has choosen Health Information Exchange Open Source (HIEOS) as a key portion of NHIN Connect.

And, HIEOS - developed by Vangent - is using several of our OpenSource components - see Architectural Diagram - including OpenESB and GlassFish, and MySQL.


PlanetMySQL Voting: Vote UP / Vote DOWN

NHIN Connect Using GlassFish and OpenESB

Октябрь 26th, 2009

The importance of information exchange in Health Care will continue to grow and the Federal Goverment has several projects to improve it, while also trying to reduce costs. And, as Bill wrote earlier in the year, Sun's Open Source has been actively engaged in this.

ALT DESCR

The goal of the National Health Information Network (NHIN) is to provide secure, nationwide, interoperable health information infrastructure that will connect providers, consumers, and others involved in supporting health and healthcare. And the CONNECT Gateway is intended to let the federal agencies connect to the NHIN.

Within the HHS, the ONC is the main entity that coordinates these efforts and it just has choosen Health Information Exchange Open Source (HIEOS) as a key portion of NHIN Connect.

And, HIEOS - developed by Vangent - is using several of our OpenSource components - see Architectural Diagram - including OpenESB and GlassFish, and MySQL.


PlanetMySQL Voting: Vote UP / Vote DOWN

NHIN Connect Using GlassFish and OpenESB

Октябрь 26th, 2009

The importance of information exchange in Health Care will continue to grow and the Federal Goverment has several projects to improve it, while also trying to reduce costs. And, as Bill wrote earlier in the year, Sun's Open Source has been actively engaged in this.

ALT DESCR

The goal of the National Health Information Network (NHIN) is to provide secure, nationwide, interoperable health information infrastructure that will connect providers, consumers, and others involved in supporting health and healthcare. And the CONNECT Gateway is intended to let the federal agencies connect to the NHIN.

Within the HHS, the ONC is the main entity that coordinates these efforts and it just has choosen Health Information Exchange Open Source (HIEOS) as a key portion of NHIN Connect.

And, HIEOS - developed by Vangent - is using several of our OpenSource components - see Architectural Diagram - including OpenESB and GlassFish, and MySQL.


PlanetMySQL Voting: Vote UP / Vote DOWN