java drivername,必须在ConnectionDriverName属性“如何解决它?”中指定JDBC驱动程序或DataSource类名。...

overview : This my first tutorial by Websphere 7 Server & JPA 1.0 & EJB & Derby Database.

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

Second : This the persistence.xml file

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">

jdbc/EJB3BANK

jdbc/EJB3BANK

Third : This partial code of Item entity Class

@Entity

@Table(schema = "SHOP", name = "ITEM")

@NamedQuery(name = "getItem", query = "SELECT i FROM Item i")

public class Item{...}

Fourth : here is the business class CartBeanhere is the start of the problem

@Stateful

CartBean implements Cart{

....

....

public List getItems() {

javax.persistence.Query query = em.createNamedQuery("getItem");//the problem here

return query.getResultList();

}

}

and This is the error message: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.

How to resolve this problem?

解决方案

Used openjpa.ConnectionDriverName property is not needed if you are referring to data source by JNDI name.

One possible cause for this issue is that persistence.xml is in the wrong location. The file must be located at the [root of class context]/META-INF. For a .war file, contents should be something like:

(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 a library .jar file packaged inside a .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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值