FileDocCategorySizeDatePackage
CreditCardBean.javaAPI DocExample4571Sat Feb 17 14:00:20 GMT 2001com.titan.customer

CreditCardBean

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

Fields Summary
Constructors Summary
Methods Summary
public voidejbActivate()

public java.lang.ObjectejbCreate(java.lang.Integer id, java.util.Date exp, java.lang.String numb, java.lang.String name, java.lang.String org)

		System.out.println("ejbCreate");

         setId(id);
		 setExpirationDate(exp);
         setNumber(numb);
         setNameOnCard(name);
         setCreditOrganization(org);
         return null;
    
public voidejbLoad()

public voidejbPassivate()

public voidejbPostCreate(java.lang.Integer id, java.util.Date exp, java.lang.String numb, java.lang.String name, java.lang.String org)

		System.out.println("ejbPostCreate");
    
public voidejbRemove()

public voidejbStore()

public abstract java.lang.StringgetCreditOrganization()

public abstract CustomerLocalgetCustomer()

public abstract java.util.DategetExpirationDate()

public abstract java.lang.IntegergetId()

public abstract java.lang.StringgetNameOnCard()

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/Titan");
                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("'CreditCard'"); //.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++;
                StringBuffer aString2 = new StringBuffer("update \"SequenceTable\" set \"CurrentValue\"="+sequenceID+" where \"SequenceName\"='CreditCard'");
                stmt2 = conn.createStatement();
                System.out.println(aString2);
                stmt2.execute(aString2.toString());
            }
            catch( Exception ex)
            {
                System.out.println("In the catch clause of CreditCardBean");
                ex.printStackTrace();
            }
        finally
            {
                try
                {
                    stmt.close();
                    stmt2.close();
                    conn.close();
                }
                catch( Exception ex)
                {
                    System.out.println("In the catch clause of finally section of CreditCardBean");
                    ex.printStackTrace();
                }
            }


            return myId;
        
public abstract java.lang.StringgetNumber()

public abstract voidsetCreditOrganization(java.lang.String org)

public abstract voidsetCustomer(CustomerLocal cust)

public voidsetEntityContext(javax.ejb.EntityContext ec)

public abstract voidsetExpirationDate(java.util.Date date)

public abstract voidsetId(java.lang.Integer id)

public abstract voidsetNameOnCard(java.lang.String name)

public abstract voidsetNumber(java.lang.String number)

public voidunsetEntityContext()