JPA连接错误URL可能无效

时间:2013-07-18 12:13:54

标签: jpa openjpa

开发环境 IBM RAD 8.5, Websphere 8.5, JSF 2.0 JPA

我尝试在JSF2.0应用程序中连接数据库时出现以下错误

There were errors initializing your configuration: <openjpa-2.2.1-SNAPSHOT-r422266:1325904 fatal user error> org.apache.openjpa.util.UserException: A connection could not be obtained for driver class "org.apache.derby.jdbc.EmbeddedDriver" and URL "jdbc:derby:F:\TrainingDB;create=true".  You may have specified an invalid URL.

persistence.xml文件如下

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">

    <persistence-unit name="TrainingJPA">       
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <class>com.ewt.traningjpa.entity.EmpTbl</class>         
        <properties>
            <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
            <property name="openjpa.ConnectionURL" value="jdbc:derby:F:\TrainingDB;create=true"/>
        </properties>

    </persistence-unit>
</persistence>

我使用RAD 8.5中提供的数据库开发选项创建了连接

我确定网址是正确的。可能是此错误的其他可能原因。

TIA

1 个答案:

答案 0 :(得分:0)

其他可能的原因:

  • 您的PC上没有映射F:驱动器
  • 您没有足够的权限将文件写入F:\ TrainingDB(可能是Windows ACL / UAC?)
  • 文件F:\ TrainingDB被其他进程锁定