Autonumber Generation in Entity Bean

Discussions

EJB programming & troubleshooting: Autonumber Generation in Entity Bean

  1. Autonumber Generation in Entity Bean (6 messages)

    I am creating a BMP that insert different value into my database table . one of my database column is autonumber generation on insertion of other values into database .
    I am getting EJBException in that identity not allowed .

    pls respond me how to deal with autonumber in BMP.

    regards
    Vipin
  2. What do you mean by auto number generation?
  3. its the same as sequence no in oracle . I am using SQL server as database and datatype of one of my column is Autonumber .
  4. What is sequence number in Oracle
  5. Can you post the finder method code? Looks like you have an incompatible type being returned for the primary key.
  6. My code is as follows


    public interface QuestionsHome extends EJBHome{
    public Questions create(String question_desc,String ans_option, String difficulty_level, String skills_id, String updated_by) throws RemoteException,CreateException;

    public Questions findByPrimaryKey(String question_id)throws RemoteException,FinderException;

    }



    public String ejbFindByPrimaryKey(String qid) throws FinderException
    {
    try
     {
        Connection cn=null;
        InitialContext ctx = new InitialContext();
         javax.sql.DataSource ds =(javax.sql.DataSource) ctx.lookup("ACESPool");
    cn = ds.getConnection();
    System.out.println("Connected to Database");
            Statement st = cn.createStatement();

       ResultSet result = st.executeQuery("SELECT * FROM ACES_QUESTIONS_MASTER WHERE QUESTION_ID=" + qid);
    if(result.next())
    return(qid);
    else
    return(null);
    }catch (Exception e)
    {
    e.printStackTrace();
    return(null);
    }
    }
    }
  7. Autonumber Generation in Entity Bean[ Go to top ]

    Your findByPrimaryKey & ejbFindByPrimaryKey return values don't match - one is "Questions" & the other is "String".

    --Das