The J2EE 1.4 Tutorial from Sun Friday, Oct 13 2006 

Sun has a valuable J2EE 1.4 tutorial. This is really good for newbies who want to study J2EE Architecture. Click here to view the tutorial.

Advertisements

Enterprise JavaBeans Sunday, Oct 8 2006 

Difference between JavaBeans and Enterprise JavaBeans
* JavaBeans are components built in Java that can be used on any tier in an application. They often thought of in relationship to servlets, and as GUI components.
* Enterprise JavaBeans are specials, server-side components used for building the business logic and data access functionality of an application.

Why use EJBs?
Even though EJBs are difficult to understand for novice, it is a powerful technology. It is scalable and flexible. The EJBs share the following tasks:
* Client Communication
* Session State Management
* Transaction Management
* Database Connection Management
* User Authentication and Role-based Authorization
* Asynchronous Messaging
* Application Server Administration

Types of EJBs
1. Session Bean (Stateless and Stateful)
2. Entity Bean
3. Message-Driven Bean

Native JDBC Java Programming Steps Sunday, Oct 8 2006 

  1. Class.forName(“com.mysql.jdbc.Driver”);
  2. Connection con = DriverManager.getConnection( “jdbc:mysql://localhost/nepatalk”, “root”, “password”);
  3. Statement st = con.createStatement();
  4. ResultSet rs = st.executeQuery(“SELECT …sql query”);
    if (rs.next())
    System.out.println(“ok”);
  5. st.close();
    con.close();

Singleton in Java Sunday, Oct 8 2006 

A singleton is a class that can be instantiated once and only once. But, why do you need them? If you are creating a class for a set up configuration and use the old fashioned class constrution, you may end up creating numerous configuration objects while you need only one copy. This singleton design pattern comes handy in this situation. You should also use Singleton when creating RMI lookup and creating JDBC connection.

How to create Singleton object?
1. Block off accessing to all constructors by making access modifier of default construtor as private.
2. Provide static method for getting an instance of the singleton.
3. Prevent cloning (usually developers forget to do; as every object inherits clone() method)

Implementation:
public class SingletonObject {

  private static SingletonObject ref;

  private SingletonObject() {
  }

  public static SingletonObject getSingletonObject() {
    if (ref == null)
      ref = new SingletonObject();
    return ref;
  }

  public Object clone() throws CloneNotSupportedException {
    throw new CloneNotSupportedException();
  }

}

Reference: http://www.javacoffeebreak.com/articles/designpatterns/index.html