Skip to Content

Sample Application - Datasource

Hi,

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.

Regards

Sidharth

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded