Skip to Content

Sample Application - Datasource


I was just going through and the sample applciation delievered with Java EE 5 and reading the documentation alongside.

The document mentions that if no datasource is specificed in persistent.xml the container will choose the default datasource. In the sample application persistent.xml is empty. I find that the default datasource is SAPJEEDB and not SAPDEMO_DS (this is checked using DBPOOL shell command GET_DS).

Hence i am not sure how the data is getting selected. The user associated with default datasource is SAPJEEDB and i checked in Database Explorer view (by creating a connection with user SAPJEEDB) that SAPJEEDB is not able to view the tables of SAPDEMO schema.

I am missing something here. Please do help me in understanding this.



Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 10:25 AM

    Hi Sidharth,

    I guess, your confusion results from ambiguous use of terminology used in the documentation... Actually, this is a very good question, and I thank you for asking it, as other people might stumble ot it as well.

    This is true, there are two preconfigured DataSources in this edition. However, the SAP<SID>DB is actually the system DataSource (i.e. used to connect to the syste DB schema, where server binaries, and other configurations reside). This DataSource is practically of no use to application developers, as at least it makes use of OpenSQL layer, and would require Java Dictionary to define DB tables. Tools support for Java Dictionary is not available in this edition... So, it's default in this sense - the system uses it for connecting to the system DB!

    Now, the SAPDEMO_DS is the DataSource, which is actually interesting for application developers. This is a native datasource that points to the SAPDEMO schema and is used by the samples in the edition, and can be used by your custom applications as well. For convenience, the JPA container has been configured in such a way that if no DataSource is explicitly defined in the persistence.xml, it'll use the SAPDEMO_DS. This is what makes the SAPDEMO_DS datasource "default" for applications.

    To summarize it all in a sentence - if your JPA application does not define its own DataSource in persistence.xml, then the JPA container will make use of the SAPDEMO_DS datasource and will connect you to the predefined SAPDEMO DB schema.

    Hope that helps a bit!

    Add a comment
    10|10000 characters needed characters exceeded

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.