Skip to Content
author's profile photo Former Member
Former Member

Database access with JSP

Hello,

i have a Java Server Page where i fill in some data in a formular. I want to put these data (only two strings) in a database. I already use a servlet to give this data to a (already existing) stateless session bean. I also created and deployed an sda, so that the table exists in the database.

But i do not understand, what to do next - how to use an entity bean to fill the table.

Can anyone give me some hints?

Thanks,

André

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2004 at 11:59 AM

    Hi Andre,

    you need to retrieve the Home Object of your entity bean and use it to create, the same way you create your session bean.

    Example:

    InitialContext initialContext = new InitialContext();

    EjbObject myEjb = null;

    try {

    java.lang.Object objRef = initialContext.lookup(EjbHome.JNDI_NAME);

    EjbHome home = (EjbHome)PortableRemoteObject.narrow(objRef, EjbHome.class);

    myEjb = home.create();

    } catch (Exception) {

    initialContext.close();

    }

    The lookup to the home object can vary, you might also have helper classes for that, it depends on your application server, API and architecture.

    But however the call or whichever the server, you basically need to retrieve the home object of your entity bean and use the method create() - with any required parameters. Pretty much the same way you create a session bean.

    Hope this helps.

    regards,

    Dionisios

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2004 at 04:13 PM

    Hi,

    thanks for your answer.

    So i created an entity bean in a project where i already have my session bean.

    When i deploy the new ear file i do not get any error messages, but when i try to start it in the browser i get an error:

    Details: java.lang.ClassCastException

    at com.sap.engine.services.ejb.deploy.orMappingVerifier.AbstractSchemaVerifier.check(AbstractSchemaVerifier.java:48)

    at com.sap.engine.services.ejb.EJBAdmin.prepareStart(EJBAdmin.java:2456)....

    (and so on)

    What does this mean?

    André

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I can't tell you exactly where your error is, for that I need more information. But you are getting a ClassCastException and that means that you are trying to handle one type of object as something else. Look at the lines of code where this error occurs and make sure you cast all objects wherever needed.

      regards,

      Dionisios

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.