cancel
Showing results for 
Search instead for 
Did you mean: 

Sample Application - Datasource

sid-desh
Advisor
Advisor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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!

sid-desh
Advisor
Advisor
0 Kudos

Hi Ivaylo,

Thanks a lot for a detailed explanation. This really helps a lot. I have few questions related to this.

Whether the default behaviour that the Persistence Container looks for SAPDEMO_DS datasource is configurable?

I have created a new user in the MaxDB database using DBM. This resulted in a new schema being generated for this user. I created few tables in this schema.

Now for me to use these tables i need to create a new Datasource. However i find that in the data-sources.dtd there is no element which indicates the database schema that would be associated with this Datasource. Is it totally ascertained by the user id and password which are present in the data-sources.dtd file.

Please do let me know your suggestions.

Regards

Sidharth Deshpande

Former Member
0 Kudos

Hi Sidharth,

yes, the DataSource is associated with the DB schema through the user name and password.

For example, if you have a schema XYZ, then in your data-source.xml file you should specify XYZ as a value of the <user-name> tag.

Regards,

Ivo

sid-desh
Advisor
Advisor
0 Kudos

Thanks Ivo.

Regards

Sidharth Deshpande

Answers (0)