FileDocCategorySizeDatePackage
ReservationBean.javaAPI DocExample4676Tue Feb 27 00:50:48 GMT 2001com.titan.reservation

ReservationBean

public abstract class ReservationBean extends Object implements javax.ejb.EntityBean

Fields Summary
Constructors Summary
Methods Summary
public voidejbActivate()

public java.lang.ObjectejbCreate(CruiseLocal cruise, java.util.Collection customers)

		System.out.println("ejbCreate");
        setId(getNextUniqueKey());
        return null;
    
public voidejbLoad()

public voidejbPassivate()

public voidejbPostCreate(CruiseLocal cruise, java.util.Collection customers)

		System.out.println("ejbPostCreate");
		setCruise(cruise);
        Collection myCustomers = this.getCustomers();
        if ( ( myCustomers != null) && (customers != null ))
		{
            myCustomers.addAll(customers);
        }
   
public voidejbRemove()

public voidejbStore()

public abstract doublegetAmountPaid()

public abstract java.util.SetgetCabins()

public abstract CruiseLocalgetCruise()

public abstract java.util.SetgetCustomers()

public abstract java.sql.DategetDate()

public abstract java.lang.IntegergetId()

private java.lang.IntegergetNextUniqueKey()

                Connection conn = null;
                Statement stmt = null;
                Statement stmt2 = null;
                ResultSet rs = null;
                boolean rowspresent = false;
                String jdbcClass = "COM.cloudscape.core.RmiJdbcDriver";
                String jdbcURL	 = "jdbc:cloudscape:rmi:TitanDB";
                String user		 = "scott";
                String password	 = "tiger";
                int sequenceID = 0;
                Integer myId = null;

                try
                {

                    InitialContext aContext = new InitialContext();
                    javax.sql.DataSource aDatasource = (javax.sql.DataSource)aContext.lookup("jdbc/TitanUID");
                    conn = aDatasource.getConnection();
                    System.out.println("Obtained a database connection to Cloudscape");

                    stmt = conn.createStatement();
                    StringBuffer aString = new StringBuffer();
                    aString.append("select ").append("\"").append("CurrentValue");
                    aString.append("\"").append(" from ").append("\"").append("SequenceTable");
                    aString.append("\"").append(" where").append("\"").append("SequenceName");
                    aString.append("\"").append("like").append("'Reservation'"); //.append(" for Update");
                    System.out.println(aString);
                    rs = stmt.executeQuery(aString.toString());
                    if (rs != null)
                    {
                        while (rs.next())
                        {
                            sequenceID =rs.getInt(1);
                        }
                    }

                    myId = new Integer(sequenceID);
                    sequenceID++;
                    stmt2 = conn.createStatement();
                    StringBuffer aString2 = new StringBuffer("update \"SequenceTable\" set \"CurrentValue\"="+sequenceID+" where \"SequenceName\"='Reservation'");
                    System.out.println(aString2);
                    stmt2.execute(aString2.toString());
                }
                catch( Exception ex)
                {
                    ex.printStackTrace();
                }
                 finally
                {
                    try
                    {
                        stmt.close();
                        stmt2.close();
                        conn.close();
                    }
                     catch( SQLException ex)
                    {
                     ex.printStackTrace();
                    }
                }
                return myId;
            
public abstract voidsetAmountPaid(double amount)

public abstract voidsetCabins(java.util.Set cabins)

public abstract voidsetCruise(CruiseLocal cruise)

public abstract voidsetCustomers(java.util.Set customers)

public abstract voidsetDate(java.sql.Date date)

public voidsetEntityContext(javax.ejb.EntityContext ec)

public abstract voidsetId(java.lang.Integer id)

public voidunsetEntityContext()