Main Menu
Home
About Me
Blog
Articles
FAQs
Contact Me
Search
Syndicate
feed image
 
   
Home arrow Blog
Quick thoughts on things
Oraclexe: getting started PDF Print E-mail
Written by Chintan Rajyaguru   
Tuesday, 15 August 2006
As part of our JavaEE development efforts, we need a database to persist our data. 

Before we move on, let's do a quick recapture of what we have done so far:

  1. We decided to do some Java EE development
  2. We downloaded, installed and configured GlassFish application server , which is an open source (beta) reference implementation of the Java EE specifications
  3. We downloaded and installed NetBeans
  4. We configured NetBeans to use GlassFish application server; we will use this setup to write code in NetBeans and deploy it on GlassFish
  5. This blog entry talks about how to install the database (will be used to persist data as part of developing JPA code) 

In my first blog about Java EE development, I had mentioned that I was going to use Oracle XE for that. The installation and configuration of Oracle XE is really easy on windows platform. You simply download Oracle XE from http://www.oracle.com/technology/products/database/xe/index.html, double click the exe, follow the prompts and you are done.

Oracle XE gives a nice browser based GUI tool to manage the database. This was easy, let's quickly create the user (schema) we will be using for Java EE development. Note the following about this db user:

  • This user is the application user that will be used to configure data source in GlassFish server for our application to interact with the database
  • This user will have connect and resource privileges on the database. Read more about privileges at http://www.oracle.com/pls/xe102/homepage
    • Connect privilege allows the user to connect to the database. Usually, applications users are given this privilege BUT we want our application user to be able to create tables (as part of JPA annotated Entity classes)
    • Resource privilege allows the user to create certain type of schema objects in his own schema (e.g. create tables, views etc.). The specific types of objects this user is allowed to create can be selected using the 'Direct Grant System Privileges' list. As shown in the screen shot below, we have selected all the options in the list
    • DBA privilege enables the user to perform administrative functions. We will not give javaee user this privilege 

To create the application user, go to Home > Administration > Manage Database Users, Click Create, Fill in the data as shown below (I am using username=javaee and password=javaee):

create_user

This step created the database schema. In Oracle, the terms user and schema are used interchangeably but I will not get into those details here. The javaee schema we just created will eventually hold all the tables, views and other database objects.

Just to make sure everything went well, we will now connect to the database and run a sql from command line:

  • Open a command prompt by selecting Run SQL Command Line from the Oracle start menu entry
  • Login as the user using connect javaee/javaee command. You should see a "connected" message
  • Save the following sql as address.sql

drop table ADDRESS;

create table ADDRESS (

"ADDRESS_ID" NUMBER NOT NULL,

"ADDRESS1" VARCHAR2(100) NOT NULL,

"ADDRESS2" VARCHAR2(100),

"CITY" VARCHAR2(50) NOT NULL,

"STATE_CODE" VARCHAR2(2) NOT NULL,

"ZIP" NUMBER NOT NULL

);

alter table ADDRESS add constraint pk_address primary key (ADDRESS_ID);

  • Run the address.sql file using SQL>@"<full_path_to_file>." Note the following about running the sql:
    • @ sign runs the sql in the file
    • Double quotes are required if your path contains spaces
    • You will get an error "table or view does not exist." This is because the first line of the script drops the table but the table doesn't exist yet. Any subsequent runs of this file won't display the error message
  • Run desc ADDRESS. This will describe the table ADDRESS 

In the next installment we will create an Address entity from the ADDRESS table. JPA also allows you to create entity classes first and use them to create database table. We will use this feature for some of the other entity classes.

View
Comments (2)
Add
Comments
Unpublish
Comments (0)
Last Updated ( Tuesday, 15 August 2006 )
 
Let's do some Java EE development PDF Print E-mail
Written by Chintan Rajyaguru   
Monday, 19 June 2006

I have been wanting to write about J2EE 5 Java EE 5 for a while now. This version has a cool collection of technologies. Look at it yourself at http://java.sun.com/javaee/technologies/. The most notable ones (at least to me) are EJB 3.0, Java Persistence API and JSF 1.2. These new standards blended with cool new technology like AJAX will make application development a lot of fun. My blood is boiling already.

Over the course of the next few days, I plan to develop a Java EE 5 application and share it here on my website. We will get all the tools necessary to develop the application (of course we will pick the tools that are freely available), we will start with the database design, we will design and develop domain entities (classes that represent the business domain) using Java Persistence API, we will design and develop stateless session bean(s) to manipulate the entities, we will develop the user interface using JSF (we might throw in some AJAX too). All the development will be done using Java SE 5.

There will be some stuff and some fluff (necessary evil to understand the stuff!). Hopefully, I will be able to organize my links in such a way that you can go through the fluff and gain conceptual understanding, or go through the stuff and learn to code in Java EE 5 quickly, or better yet, go through stuff and fluff in iterative manner and do both. 

Let's get started!

Any developer wanting to learn about new technologies, thinks about the tools he/she will need to write code. Since we want to write a Java EE application, we need to look for a container that implements Java EE 5 specifications. 

On a side note, I can see why Sun wanted to get rid of the "2" in J2EE and hence the new name Java EE. And since this versions comes after 1.4, the name becomes Java EE 5, it's too long and difficult to say (and write) it correctly every time. I am simply going to write Java EE to mean Java EE 5 - the latest specification in enterprise edition of Java. Similarly, I am going to use Java SE (or even JDK) to mean Java SE 5. 

Back to the tools. I have selected Glassfish - an open source, free application server that implements Java EE specifications and Netbeans - an open source IDE to develop applications in Java EE. You can use other servers such as Jboss, Sun Java System Application Server (Glassfish's commercial brother) and Oracle Application Server and weblogic. As of this writing, IBM WebSphere and Apache Geronimo don't seem to be having a Java EE implementation yet.

I chose glassfish because it's pretty quick in implementing the new features and there are quite a bit of learning resources on https://glassfish.dev.java.net/. Similarly Netbeans has everything you need to develop Java EE applications. Please note that I am not a proponent or opponent of these or any other tools, I just picked the ones that I thought would make it easier to develop Java EE applications. 

Besides Java EE, we will need a database server. I chose Oracle eXpress Edition. Again, I could have used Derby, Cloudscape, mysql or something else. I just like to use the tools that I might end up using in the real world. After all, most of my clients use Oracle, DB2 or SQL Server.

See if you can download and install glassfish, Netbeans and Oracle XE. Next time, I will post the installation instructions.

Hint: You will have a port conflict between glassfish and Oracle XE. Fix it if you can or wait for the next installment.

 

View
Comments (2)
Add
Comments
Unpublish
Comments (0)
Last Updated ( Monday, 19 June 2006 )
 
BlogSidebar
 
 

Copyright Chintan Rajyaguru
Contact me if you have any questions or comments.