【问题标题】:OpenJPA Connection errorOpenJPA 连接错误
【发布时间】:2012-11-11 13:10:39
【问题描述】:

我正在关注 OpenJPA 上的本教程 -> http://plunchete.wordpress.com/2007/05/06/using-openjpa/

我收到此错误:

160  INFO   [main] openjpa.Runtime - OpenJPA dynamically loaded the class enhancer. Any classes that were not enhanced at build time will be enhanced when they are loaded by the JVM.
188  INFO   [main] openjpa.Runtime - Starting OpenJPA 2.2.1
Exception in thread "main" <openjpa-2.2.1-r422266:1396819 fatal user error
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class
name must be specified in the ConnectionDriverName property. Available properties in
configuration are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
at
org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)

Persistence.xml 是这样的:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
<persistence-unit name="example" transaction-type="RESOURCE_LOCAL">
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
<class>Person</class>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/cs5200" /
<property name="openjpa.ConnectionUserName" value="root" />
<property name="openjpa.ConnectionPassword" value="" />
</properties>
</persistence-unit>
</persistence>

【问题讨论】:

  • 有人对此有任何想法吗?
  • 你能和我们分享你的persistence.xml吗?
  • 我现在在中国写信,没有wordpress :)
  • @jedrus07 我已经添加了
  • 看起来您可能没有所需的 com.mysql.jdbc.Driver。您是否将其包含在您的 POM 文件中(鉴于这是一个 Maven 项目)?所需的条目是:mysqlmysql-connector-java5.1.6

标签: java hibernate jpa persistence openjpa


【解决方案1】:

错误是文件夹结构错误。

META-INF 应该在 src 文件夹中。

不是那样的。我研究并测试了不同的东西并想出了这个解决方案。

希望以后对大家有所帮助。

【讨论】:

  • 我正要对此发表评论。很高兴您找到了解决方案! - 不要忘记接受你自己的答案!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-10
  • 2016-08-10
  • 1970-01-01
  • 2019-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多