Thursday October 01, 2009
TOTD #106 explained how to install Oracle database 10g R2 on Mac OS X. TOTD #107 explained how to connect this Oracle database using NetBeans. This Tip Of The Day will explain how to use the sample HR database (that comes with Oracle database server) to write a simple Java EE 6 application.
This application will use Java Server Faces 2.0 for displaying the results, Enterprise Java Beans 3.1 + Java Persistence API 2.0 for middle tier, and Oracle database server + GlassFish v3 as the backend. The latest promoted build (65 of this writing) will not work because of the issue #9885 so this blog will use build 63 instead.
Several improvements have been made over NetBeans 6.8 M1 build and this blog is using the nightly build of 9/27. The environment used in this blog is:
Lets get started!
./bin/asadmin start-domain --verbose &
./bin/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
./bin/asadmin ping-connection-pool jdbc/hr
./bin/asadmin create-jdbc-resource --connectionpoolid jdbc/hr jdbc/hr









@javax.ejb.Stateless
@javax.faces.bean.ManagedBean
@PersistenceUnit
EntityManagerFactory emf;
public List getEmployees() {
return em.createNamedQuery("Employees.findAll").getResultList();
}
@Stateless
@ManagedBean
public class EmployeesBean {
@PersistenceContext
EntityManager em;
public List getEmployees() {
return em.createNamedQuery("Employees.findAll").getResultList();
}
}
<h1>First Java EE 6 app using Oracle database</>
<h:dataTable var="emp" value="#{employeesBean.employees}" border="1">
<h:column><h:outputText value="#{emp.lastName}"/>, <h:outputText value="#{emp.firstName}"/></h:column>
<h:column><h:outputText value="#{emp.email}"/></h:column>
<h:column><h:outputText value="#{emp.hireDate}"/></h:column>
</h:dataTable>

So we can easily create a Java EE 6 application using NetBeans, Oracle, and GlassFish.
A complete archive of all the TOTDs is available here.
This and other similar applications will be demonstrated at the upcoming Oracle Open World.
Technorati: totd oracle database glassfish v3 javaee javaserverfaces ejb jpa netbeans oow
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
| Running Summary Q3 2009 – 400 miles, 80% of running days
Here is the summary of my running logs from Q3 2009 (Jul - Sep):

Even though 3 days of less running than Q2, but the overall mileage was increased. Barely hit that 400 miles mark in Q3 and it did took some extra efforts to reach there ;-) But now tapering for the upcoming Rock-n-Roll 1/2 Marathon this weekend.

5 miles was the most favorite distance being run 17 times and 19.7 miles and 17.4 miles were run only once.
Would you like to generate similar charts for your running logs as well ?
This can be easily achieved using a Rails application or a Wicket application on GlassFish.
Technorati: rails wicket glassfish running rnrsj
Posted by Arun Gupta in Running | Comments[0]
|
|
|
|
|
Today's Page Hits: 624
Total # blog entries: 1002