Hello !!!

I'm trying to deploy a BMP EJB.
The server gets initialized and I can see the new deployed BMP Entity
Bean in the orioin-ejb-jar.xml file.(I hope this means that the bean has
been deployed...)

My first question is that do we have to create a table ourself in case
of BMP EJB...????

Well after a 2-3 failed deployments I created a table( so I guess that
in case of BMP we have to first create a table....... anyway, I did)

Now when I create the bean (i.e. try to add value to the database)
Everything seems to be going fine.
It refuses to take duplicate values... 

But when I look into the database I cannot see any data and the table is
empty...

If I restart the server (orion ofcourse) I can the same scene repeats...

Where does Orion save the data, if it is not using any database...???
And wht exactly is going on..??? Where can I be wrong..???

Till now I happy working with CMPs and thought BMP might just be as
easy... 
I cant figureout where am i stuck.

I'm using Cloudscape as my database...

The EJBClass file is like ....


        public AddUserBMPPK ejbCreate(int id,int age,String name){
        //public AddUserBMPPK ejbCreate(int id,String address,int
age,String email,String name,String phone){
                this.id=id;
                this.name=name;
                this.age=age;
                //this.address=address;
                //this.email=email;
                //this.phone=phone;
 
                Connection con = null;
                Statement stmt = null;
                try{
                   con = this.getConnection();
                   stmt= con.createStatement();
                   String sql = "insert into AddUserBMPBean
(id,name,age) values ('"+id+"','"+name+"','"+age+"')";
                   int bi = stmt.executeUpdate(sql);
                  //ResultSet rst = stmt.executeQuery(sql);
 
                   //sql = "insert into AddUserBMPBean
(id,address,email,phone) values
('"+id+"','"+address+"','"+email+"','"+phone+"')";
                   //bi = stmt.executeUpdate(sql);
 
                   AddUserBMPPK primKey = new
AddUserBMPPK();                         
                   primKey.id = id;
 
                //System.out.println("ejbCreate( \"AddUserBMPPK\" int
"+id+",String "+address+",int "+age+",String "+email+",String
"+name+",String "+phone+")");
                System.out.println("ejbCreate( \"AddUserBMPPK\" int
"+id+",int "+age+",String "+name+")");
 
                return primKey; //return primary key when using BMP
                }catch(SQLException se){
                        System.out.println("Exception in create line 49
.."+se.toString());
                        throw new EJBException(se);
                }//catch
                finally{
                    try{
                        if( stmt != null) stmt.close();
                        if( con != null) con.close();
                    }catch(SQLException se){
                        se.printStackTrace();
                    }//catch
                }//finally
        }//ejbCreate                                  

        public void ejbLoad(){
           AddUserBMPPK pk = (AddUserBMPPK) context.getPrimaryKey();
                Connection con = null;
                Statement stmt = null;
                ResultSet rst = null;
              try{
                con = this.getConnection();
                stmt= con.createStatement();
                String sql = "select id,name,age from AddUserBMPBean
where id ="+pk.id;
                System.out.println("in ejbLoad of AddUserBMPBean");
                rst = stmt.executeQuery(sql);
                if( rst.next() ){
                  id = rst.getInt("id");
                  name = rst.getString("name");
                  age = rst.getInt("age");
                System.out.println(id+",  "+name+",  "+age);
                } else {
                 throw new EJBException();
                }//else
              }catch(SQLException se){
                  throw new EJBException(se);
              }//catch
                finally{
                    try{
                        if( stmt != null) stmt.close();
                        if( con != null) con.close();
                        if( rst != null) con.close();
                    }catch(SQLException se){
                                                              
                        se.printStackTrace();
                    }//catch
                }//finally
        }//ejbLoad


    private Connection getConnection() throws SQLException {
 
       Connection connection;
       InitialContext initialContext = null;
 
              try {
                initialContext = new InitialContext();
                } catch ( Exception ex ){
                System.out.println( "-- Getting Initial Context --" );
                ex.printStackTrace( System.err );
                throw new EJBException( "getting Sequence
InitialContext, " + ex.getMessage() );
                }//catch
 
                String dsName = "jdbc/DefaultEJBHello";
              try {
                DataSource ds = (DataSource) initialContext.lookup(
dsName );
                System.out.println( "-- (DataSource)
initialContext.lookup( "+dsName+" ) --" );
                return ds.getConnection();
 
                }catch ( Exception ex ) {
                  System.err.println( "-- looking up DataSource '" +
dsName + "' --" );
                ex.printStackTrace( System.err );
                throw new EJBException( "looking up dsName '"+ dsName +
"', " + ex.getMessage() );
                }//catch
    } //getDBConnection                     


 
       
------------------------------------------------
The Deployment descriptor is:--


 
                <entity>
                        <description>First BMP EJB to add user to table
PROFILEBEAN</description>
                        <display-name>AddUserBMPBean</display-name>
                        <ejb-name>AddUserBMPBean</ejb-name>
                        <home>hello.BMPEntityBeans.AddUserBMPHome</home>
                        <remote>hello.BMPEntityBeans.AddUserBMP</remote>
                       
<ejb-class>hello.BMPEntityBeans.AddUserBMPBean</ejb-class>
                        <persistence-type>Bean</persistence-type>
                       
<prim-key-class>hello.BMPEntityBeans.AddUserBMPPK</prim-key-class>
                        <reentrant>False</reentrant>
                </entity>
                                        
----------------------------------------------------------


The orion-ejb-jar.xml entry for this Bean is:--

              <entity-deployment name="AddUserBMPBean"
location="AddUserBMPBean" wrapper="AddUserBMPHome_EntityHomeWrapper21"
table="AddUserBMPBean">
                </entity-deployment>         



I desperately need some help...
Thanks ,
Ishpal.

Reply via email to