The JDBC class name or the DataSource class name must be specified in the ConnectionDriverName property "How to solve it?".

overview: this is my first tutorial on Websphere 7 Server and JPA 1.0 and EJB and Derby Database.

First: My data source name is EJB3BANK, and my target database is SHOP.

Second: this is persistence.xml file

<?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="ShopJPA" transaction-type="JTA"> <jta-data-source>jdbc/EJB3BANK</jta-data-source> <non-jta-data-source>jdbc/EJB3BANK</non-jta-data-source> <properties> <property name="openjpa.jdbc.Schema" value="SHOP" /> </properties> </persistence-unit> </persistence> 

Third: this partial code Element object class

 @Entity @Table(schema = "SHOP", name = "ITEM") @NamedQuery(name = "getItem", query = "SELECT i FROM Item i") public class Item{...} 

Fourth: here is the CartBean business class, here is the beginning of the problem

 @Stateful CartBean implements Cart{ .... .... public List<Item> getItems() { javax.persistence.Query query = em.createNamedQuery("getItem");//the problem here return query.getResultList(); } } 

And this error message: The JDBC class name or DataSource class name must be specified in the ConnectionDriverName property . How to solve this problem?

+6
source share
7 answers

The openjpa.ConnectionDriverName property used is not required if you are referencing a data source named JNDI.

One possible reason for this problem is that persistence.xml is in the wrong place. The file must be in the [root of class context] / META-INF directory. For a .war file, the content should look something like this:

 (foo.war) WEB-INF/classes/META-INF/persistence.xml WEB-INF/classes/com/foo123/jpa/Project.class WEB-INF/web.xml index.jsp 

and for the library .jar file packaged inside the .war file:

 (foo.war) WEB-INF/lib/my-library.jar WEB-INF/web.xml index.jsp (my-library.jar) META-INF/persistence.xml com/foo123/jpa/Project.class 
+9
source

post jpa

The JDBC class name or DataSource class name must be specified in the ConnectionDriverName Property

is a misleading message. It does not help to understand the problem. It would be better something like:

jta-data-source - jdbc / EJB3BANK not available / not available

because this is what happens. You may have included the jpa project in your web or ejb project (or maybe not, you could have added jpa faces directly to one of these projects), however, once you have created the jdbc connection in the webshpere console, the best way to use it:

  • change your persistence.xml (AnyJpaProject / src / META-INF / persistence.xml)

     <jta-data-source>java:comp/env/jdbc/EJB3BANK</jta-data-source> 
  • make sure your web.xml / ejb-jar.xml has something like:

     <resource-ref> <description></description> <res-ref-name>jdbc/EJB3BANK</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> 
  • add to ibm-ejb-jar-bnd.xml / ibm-web-bnd.xml:

<resource-ref name="jdbc/EJB3BAN" binding-name="jdbc/EJB3BAN">

I hope for this help.

+3
source

I think this is a mistake in the implementation of the JPA provider. I get a similar error, but in my case I did not actually enter the name of the data source. The reason is that standards allow you to use the concept of a default data source. Unfortunately, it does not work with WebSphere Application Server 8.0.0.1 and RSA 8.0. Not sure PMR has also been registered.

+2
source

Just to add an answer to eis (sorry, not enough comments for comments):

Using Eclipse my persistence.xml was originally located in the src SRC / persistence.xml root folder

Moving to SRC / META-INF / persistence.xml fixed my problem as Eclipse automatically translates it to the assembly directory.

Not all ORM (object-relational mapping) APIs work this way, although I am sure that using hibernate of my hibernate.cfg.xml (persistence.xml) was always right in the src folder.

+1
source

This is an error that cannot use the name of the data source in the persistence.xml file after adding datasoruce to the application server. However, it will work if you add properties to the persistence.xml file as shown below.

  <property name="openjpa.ConnectionURL" value="DB URL"/> <property name="openjpa.ConnectionDriverName" value="Driver Name"/> <property name="openjpa.ConnectionUserName" value="userid"/> <property name="openjpa.ConnectionPassword" value="password"/> 
+1
source

I think that you are trying to define a new Datasource by declaring it in the persistence.xml file, and it lacks a property like <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver" />

However, since you are using Websphere, I suggest you create a data source through the Webspheres administration console (Webinterface). In the Resources-> JDBC section, you first create the JDBC Provider and tell it to use the Derby Driver. And after that you will create a new Datasource using this provider. There you can define a JNDI binding. Set the value of jdbc / EJB3BANK . And you, the current persistence.xml, should work if it is supposed to.

0
source

try these people:

  <persistence-unit name="ShopJPA" transaction-type="JTA"> <jta-data-source>jdbc/EJB3BANK</jta-data-source> <non-jta-data-source>jdbc/EJB3BANK</non-jta-data-source> <class>jdbc/EJB3BANK</class> <properties> <property name="openjpa.jdbc.Schema" value="SHOP" /> </properties> </persistence-unit> </persistence> 

I don't know if there should be "jdbc / EJB3BANK" or just "EJB3BANK" in the node class, try two options. = D This works for my

0
source

Source: https://habr.com/ru/post/889769/


All Articles