on 11-14-2006 7:12 AM
Hi Everybody
I am using following persistence.xml with provider (oracle) and its work fine but what if I want to use SAP provider.
Please give the persistence.xml for SAP
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="polo">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<class>entity.Customer</class>
<class>entity.Order</class>
<properties>
<property name="toplink.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="toplink.jdbc.url" value="jdbc:jtds:sqlserver://localhost:1433/persistence"/>
<property name="toplink.jdbc.user" value="sa"/>
<property name="toplink.jdbc.password" value=""/>
<property name="toplink.target-database" value="oracle.toplink.essentials.platform.database.SQLServerPlatform"/>
<property name="toplink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
</persistence>
Thank You
Best Regards,
Syed Saifuddin
Hi Syed,
from the persistence.xml file, it appears that you want to use JPA in a Java SE environment. Although this is technically possible with SAP JPA, we have no well-defined way to fully support the JPA / Java SE scenario yet. We are currently clarifying the terms and conditions of the standalone usage of SAP JPA.
Of course you are are very welcome to use SAP JPA in a Java EE envirnoment. The easiest way to do this is to write a little servlet that invokes your persistence coding.
In an Java EE environment, the persistence.xml would read like this (assumming that you are using the schema SAPDEMO provided with the Java EE 5 edition):
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="polo"/>
</persistence>
You might also specify the data source explictly:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="polo">
<jta-data-source>YOUR_DATASOURCE_NAME</jta-data-source>
</persistence-unit>
</persistence>
The persistence provider defaults to SAP JPA. The database dialect is detected automatically. In a Java EE environment, the entities are detected automatically.
Best regards,
Adrian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Syed,
As Adrian already explained, you don't even need this <jta-data-source> tag in your persistence.xml if you decide to use the default applications datasource SAP/JPA_DEFAULT (and hence the SAPDEMO database schema provided with the Java EE 5 server).
However, if you want to use another (custom) datasource, in the <jta-data-source> tag you specify its name, e.g.
<jta-data-source>MyDataSource</jta-data-source>
Then you need to create this datasource MyDataSource. For more information please refer to the document https://www.sdn.sap.com/irj/sdn/?rid=/webcontent/uuid/28b1ed0e-0d01-0010-c887-a8fdecdb9053">documentation [original link is broken] [original link is broken] as well as from the Developer Studio help contents. There you can also find the topic "Developing a Real Java EE 5 Application" which explains and demonstrates (amongst other subjects) the use of JPA in a Java EE environment.
Hope that helps!
-Vladimir
Hi Vladimir Pavlov
I make the file data-sources.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE data-sources SYSTEM "data-sources.dtd" >
<data-sources>
<data-source>
<data-source-name>YT</data-source-name>
<driver-name>SQLSERVER</driver-name>
<sql-engine>sql-engine</sql-engine>
<jdbc-1.x>
<driver-class-name>net.sourceforge.jtds.jdbc.Driver</driver-class-name>
<url>jdbc:jtds:sqlserver://localhost:1433/persistence</url>
<user-name>sa</user-name>
<password></password>
</jdbc-1.x>
</data-source>
</data-sources>
I put data-sources.xml in the same META-INF directory
still its not working
Any idea is appreciated
the error it produces is
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named polo
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at com.client.Client.main(Client.java:46)
Hi Vladimir Pavlov
Is there any link to example that run on JEE5 SAP SERVER with using any other database . other then default.
The thing close to clear but not clear to me is , what is the replacement of
<property name="toplink.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="toplink.jdbc.url" value="jdbc:jtds:sqlserver://localhost:1433/persistence"/>
<property name="toplink.jdbc.user" value="sa"/>
From
toplink.jdbc.
To
???
Please make it clear
Thank You
Syed Saifuddin
You have to define a new datasource (let us call it SQLSERVER) to you desired DB and deploy it either as datasource.xml as mentioned above or you create a new datasource using Netweaver Administrator. Then you can refer to this data-source in your persistence.xml with the <jta-datasource>SQLSERVER</jta-datasource> element. With that your persistence unit will run on the SQLSERVER datasource. The properties you mentioned are all toplink-specific and are not needed in this case.
Best Regards,
Robin
Hi Robin De Silva Jayasinghe
The following Exception occur while deploying the dataSource through Telnet.
Exception occurred during DataSource(s) deployment: com.sap.engine.services.dbp
ool.exceptions.BaseRemoteException: Error occurred while deploying component ".\
temp\dbpool\data-source.xml.sda".
Thank you
Syed Saifuddin
Hi Syed,
Have you already checked the links above? There it is described in details how to create your own custom datasource, how to deploy it, how to deploy a JDBC driver (which you will need since your database is not the MaxDB but MSSQL) and so on, and so on. Please check pages 12-16.
Note that the data-sources.xml is an XML file according to the data-sources.dtd, not an SDA archive!
-Vladimir
Hi Syed,
we as the team that is developing the JPA runtime are currently preparing a series of articles that is focused on the usage and concepts of JPA. The first article is already in the SDN-submission process. So look out at the Java EE 5 topic page the following days.
Regarding you data-source problem you might have a try on Netweaver Administrator and create a data-source there. Maybe this is more intuitive than the telnet-console. Check the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/806e75a0-0e01-0010-2587-fc518de8ac1a">NWA guide</a> (pages 225 and folllowing ) for a detailed description.
Additionally to our documentation I can recommend to read the <a href="http://java.sun.com/javaee/technologies/entapps/persistence.jsp">official JPA-pages at java.sun.com</a>.
Best Regards,
Robin
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.